我正在使用yii2 with twig并尝试在我的模板中使用任何资产类。我正在尝试我自己的类,或者提供yii2的类,但它们都没有工作,它们都没有引起任何错误。 在我的声明下面:
<!DOCTYPE html>
<!-- Below declaration doesn't work - try to fix it later -->
{{ use ('/frontend/assets/AppAsset' )}}
{{ register_app_asset() }}
<html lang="{{app.language}}">
<head>
<meta charset="{{app.charset}}"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Other head stuff -->
{{ html.csrfMetaTags()|raw }}
<title>
{{html.encode(this.title)}}
</title>
{{this.head()}}
</head>
什么都不做_我没有注册脚本也没有任何错误。 谢谢你的帮助
答案 0 :(得分:4)
我遇到了同样的问题,这对我有用:
{{ use('frontend/assets/AppAsset')}}
{{ register_app_asset() }}
从您的代码判断,我能看到的唯一区别是您在use斜杠前面添加了使用函数参数。