Vue与原生JS中方法调用
实例JSmethods.js 中定义两个方法let = printHello = function () {console.log('Hello');}function printWorld(){console.log('World');}页面引入<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js">
·
实例
- JSmethods.js 中定义两个方法
let = printHello = function () {
console.log('Hello');
}
function printWorld(){
console.log('World');
}
- 页面引入
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script>
<script src="./JSmethods.js"></script>
- 调用
<script>
console.log('JS中调用');
printHello();
printWorld();
printJS();
function printJS(){
console.log('JavaScript');
}
new Vue({
methods:{
inVue(){
console.log('Vue的methods调用');
printHello()
printWorld()
printJS()
}
},
created:function(){
this.inVue()
console.log('created中调用');
printHello()
printWorld()
printJS()
}
})
</script>
- 打印结果
更多推荐
已为社区贡献4条内容
所有评论(0)