The first is the question of how the two issues introduced:
First: js file folder can not be placed components
Method a: direct reference within the assembly
`import swiper from './swiper.js'`
Method Two: Global register references
function aa(){
console.log("11");
}
export { one }
import one from './common/js.js';
Vue.prototype.ss=one;
this.ss.aa(); //在需要的地方使用
Js loading method in a certain order:
Load js file clickOne event runs is equivalent to: a method
Components within the code:
<script>
import {one} from '../js/one.js' //接收js内暴露的对象
export default {
data () {
return {
testvalue: '11'
}
},
methods:{
clickOne:function(){
one(); //运行
}
}
}
</script>
one.js within the code:
function ss() {
console.log('1111111111');
}
export { one } //很重要 要暴露出去
Method two: with a method similar to that in mounted
calling within the hook function
<script>
import {one} from '../js/one.js' //接收js内暴露的对象
export default {
data () {
return {
testvalue: ''
}
},
mounted(){
clickOne:function(){
one(); //运行
}
}
}
</script>
one.js within the code:
function ss() {
console.log('1111111111');
}
export { one } //很重要 要暴露出去