我遇到了一些问题。从视图来看,appendFile 似乎不起作用。如果我将其更改为 prependFile,它具有相同的行为。
布局.phtml
<!doctype html>
<html lang="en" dir="ltr">
<head>
<?php
$this->headScript()->appendFile('http://code.jquery.com/ui/1.10.3/jquery-ui.js');
$this->headScript()->appendFile('/theme/javascripts/application.js');
$this->headScript()->appendFile('/js/own.js');
?>
</head>
<body>
<?php echo $this->layout()->content; ?>
<?php echo $this->headScript() ?>
</body>
</html>
索引.phtml
<?php $this->headScript()->appendFile('/js/another.js') ?>
输出
<!doctype html>
<html lang="en" dir="ltr">
<head>
</head>
<body>
<script type="text/javascript" src="/js/another.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="/theme/javascripts/application.js"></script>
<script type="text/javascript" src="/js/own.js"></script>
</body>
</html>
如您所见,/js/another.js 将是第一个 js。这不是我想要的,我想把它放在最后。有谁知道怎么了?