This is the situation of the console in the imported js
This is the case in elements
nav has not changed either.
How is this going?
仅有的幸福2017-07-05 10:44:02
I don’t see where the problem is. When asking questions, first clarify your thoughts and expose the problem points.
Answer questions
Can’t js be introduced into the vue project to control the class of elements?
It is possible to introduce tools such as jQuery to operate the dom
仅有的幸福2017-07-05 10:44:02
In fact, it is very convenient to deal with such problems in VueJS, here is an example.
View online https://jsfiddle.net/wqbtt12c/
The specific code is as follows:
<p id="app">
<p :class="classStr" @click="changeClass">点我</p>
</p>
const classPool = ['red', 'blue', 'yellow'];
new Vue({
el: '#app',
data() {
return {
classStr: 'red'
}
},
methods: {
changeClass() {
this.classStr = classPool[Math.ceil(Math.random()*3.0) - 1];
}
}
});
#app > p {
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
}
.red {
background: red;
}
.blue {
background: blue;
}
.yellow {
background: yellow;
}
过去多啦不再A梦2017-07-05 10:44:02
In the vue project, the operation must be mounted after the element to be operated is mounted. I fainted.