【发布时间】:2018-01-08 17:12:27
【问题描述】:
我在 app.js 中添加了一个 js 方法:
require('./bootstrap');
window.Vue = require('vue');
Vue.component('example', require('./components/Example.vue'));
const app = new Vue({
el: '#app'
});
function hello()
{
alert("hello");
}
然后编译我的资产并将 app.js 添加到我的视图中:
<script src="{{ asset('js/app.js') }}"></script>
如果我此时加载我的视图并查看源代码,我可以看到 app.js 的链接,如果我打开该 app.js,我可以在其中看到我的 hello 方法以及许多其他内容。
现在当我想调用我的方法时,我会尝试这样做:
<a onclick="hello();">
但在我的控制台中,我得到一个 Uncaught ReferenceError: hello is not defined 错误。可能是什么问题?
【问题讨论】:
标签: javascript laravel laravel-5