我有一个vue组件
vue-compoennt(vue-loader)
<template>
<p>This is a template</p>
</template>
<script>
require('main.js')
huha()
</script>
Run Code Online (Sandbox Code Playgroud)
我有
main.js
var huha = function(){
alert("this is huha");
};
alert("this is simple alert");
Run Code Online (Sandbox Code Playgroud)
在这里,我得到了"简单警报",但在评估huha()时,它显示了参考错误.有人可以帮我理解为什么会这样吗?
编辑
我试图使用testimonial.js如下,我得到参考错误.
<template>
<p>This is a template</p>
<div id="testimonial-slider"></div>
</template>
<script>
require('testimonial/testimonial.js')
require('testimonial/testimonial.css')
var testimonial = new Testimonial('#testimonial-slider');
</script>
<style>
p{
color: red;
}
</style>
Run Code Online (Sandbox Code Playgroud)
它给出了"参考错误:证词没有定义"