-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtest.js
More file actions
58 lines (50 loc) · 1.36 KB
/
test.js
File metadata and controls
58 lines (50 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// document.write('<script type="text/javascript" charset="utf-8" src="iview/test1.js"></script>')
var el=document.querySelector('head')
var importjs=function(jspath){
var newElement = document.createElement('script');
newElement.setAttribute('type','text/javascript');
newElement.setAttribute('src',jspath);
el.appendChild(newElement)
console.log('成功引入js')
}
var generateParentNode=function(el,classname){
elem = document.createElement('div')
elem.className=classname
el.parentNode.replaceChild(elem,el)
elem.appendChild(el)
}
importjs('javascript/test_1.js')
var testImportJs=function(){
var a=test_1();
return 'testImportJs-'+a+1
}
var creatVueApp=function(){
const app3 = new Vue({
el: '#app3',
data() {
return{
msg:'引入js手动新建app3'
}
},
methods:{
testApp3Click(){
this.msg='app3-测试vue点击'
}
}
}).$mount('#app3')
}
document.addEventListener("DOMContentLoaded", function(event) {
const app4 = new Vue({
el: '#app4',
data() {
return{
msg:'引入js自动创建app4'
}
},
methods:{
testApp4Click(){
this.msg='app4-测试vue点击'
}
}
}).$mount('#app4')
})