the best way to include js file in zend framework

后端 未结 2 1483
后悔当初
后悔当初 2021-01-12 11:15

I want to include external js file in my php script. I am following zend framework.Right now I am adding js file in controller\'s init function like this.

pu         


        
2条回答
  •  北恋
    北恋 (楼主)
    2021-01-12 11:56

    In above solution the 'path/to/file.js' script will be included in the header twice. There is no need for echo before calling prependFile. Such behaviour can lead to duplicating javascript controls.

    headScript()->prependFile( $this->baseUrl('path/to/file.js')) // this will echo out the whole prependFile queue

提交回复
热议问题