我如何添加js文件时,只有/user/settings html加载


How can i add the js file only when the /user/settings html load

我在布局中有一组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>

但是不要回显它——它会被添加到你的布局列表中,并被放置在那里。