【发布时间】:2020-03-31 03:14:18
【问题描述】:
我已经从这个 git 存储库https://github.com/mikermcneil/ration下载了 Sails + VueJs 框架示例代码
但是发现无法在Vue前端框架中使用Axios、Vutify等外部库。请帮我解决这个问题。
【问题讨论】:
我已经从这个 git 存储库https://github.com/mikermcneil/ration下载了 Sails + VueJs 框架示例代码
但是发现无法在Vue前端框架中使用Axios、Vutify等外部库。请帮我解决这个问题。
【问题讨论】:
您应该可以将它们放在assets/dependencies folder 中。下次 Grunt 进行构建时,它会将脚本包含在 layout.ejs 文件中。不要直接从 layout.ejs 文件中引用它,因为每次 Grunt 检测到更改时都会覆盖它。
就实例化任何脚本而言,您可能希望在每个页面的 Javascript 文件 assets/js/pages/{name-of-page} 上执行此操作。在 beforeMount 或 Mounted 生命周期方法中。该方法也是您对页面数据进行水合的地方:
beforeMount: function() {
//Instantiate script here
}
【讨论】: