Php 如何仅在/user/settings html加载时添加js文件

Php 如何仅在/user/settings html加载时添加js文件,php,zend-framework2,view-helpers,Php,Zend Framework2,View Helpers,我在layout.phtml中有一组js文件,但我不需要一次加载所有的js文件,而是需要在各个页面上加载。我该怎么做呢 <?php echo $this->headScript() ->appendFile($this->basePath() . '/js/jquery.js') ->appendFile($this->basePath() . '/js/jquery-1.9.1.min.js') ->ap

我在layout.phtml中有一组js文件,但我不需要一次加载所有的js文件,而是需要在各个页面上加载。我该怎么做呢

<?php echo $this->headScript()
        ->appendFile($this->basePath() . '/js/jquery.js')
        ->appendFile($this->basePath() . '/js/jquery-1.9.1.min.js')
        ->appendFile($this->basePath() . '/js/jquery-ui.js')
        ->appendFile($this->basePath() . '/js/bootstrap.min.js')
        ->appendFile($this->basePath() . '/plugins/underscore/underscore-min.js')
        ->appendFile($this->basePath() . '/plugins/moment/moment.js')
        ->appendFile($this->basePath() . '/plugins/pace/pace.min.js')
        ->appendFile($this->basePath() . '/plugins/wysiwyg/bootstrap3-wysihtml5.all.min.js')
        ->appendFile($this->basePath() . '/plugins/validator/bootstrapValidator.min.js')

        ->appendFile($this->basePath() . '/plugins/clock-picker/clockpicker.js')

        ->appendFile($this->basePath() . '/plugins/bootstrap-calendar/js/calendar.js')
        ->appendFile($this->basePath() . '/plugins/Chart.js-master/Chart.js')
        ->appendFile($this->basePath() . '/js/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9',))
        ->appendFile($this->basePath() . '/js/html5shiv.js',   'text/javascript', array('conditional' => 'lt IE 9',))

        ->appendFile($this->basePath() . '/js/main.js')
        ->appendFile($this->basePath() . '/js/profile.js')
        ->appendFile($this->basePath() . '/js/profile_12.js')
        ->appendFile($this->basePath() . '/js/profile_2.js')
        ->appendFile($this->basePath() . '/js/profile_users_medical_events.js')

        ->appendFile($this->basePath() . '/plugins/cropper/cropper.min.js')
        ->appendFile($this->basePath() . '/js/profile-photo.js')
        ->appendFile($this->basePath() . '/js/select2.min.js')
        ->appendFile($this->basePath() . '/js/selectize.min.js')
        ->appendFile($this->basePath() . '/js/new_appointment.js')
        ->appendFile($this->basePath() . '/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.js')
        ->appendFile($this->basePath() . '/js/users_profile_chart.js')
        ->appendFile($this->basePath() . '/js/livestamp.min.js')
        ->appendFile($this->basePath() . '/js/res.js')

        ->appendFile($this->basePath() . '/js/rec.js')
        ->appendFile($this->basePath() . '/js/settings.js')

     ; ?>


我需要的是只加载所需的js文件。

就像在layout中那样-您可以在视图中调用帮助程序

<?php $this->headScript()->appendFile($this->basePath() . 'my.js') ?>

<h2>Some Heading</h2>

一些标题

但不要回显它-它将附加到布局中的列表中并放置在那里。

就像在布局中那样-您可以在视图中调用帮助器

<?php $this->headScript()->appendFile($this->basePath() . 'my.js') ?>

<h2>Some Heading</h2>

一些标题
但不要重复它-它将被附加到布局中的列表中,并放置在那里