Home >Web Front-end >JS Tutorial >How to insert variable parameters in tag attributes in vue.js
This time I will show you how vue.js inserts variable parameters into tag attributes. What are the precautions for vue.js to insert variable parameters into tag attributes? The following are This is a practical case, let’s take a look at it.
html tag’s attributes, such as id, class, href need to dynamically pass parameters and splice strings. I checked some information and did not find a suitable solution. Method, after thinking about it all morning, I finally tried the method:
v-bind: attribute = "'string'+selfdefine variable name ”, I tried it myself and it’s no problem, friends in need can learn from it!
Finally, please note that the attribute must be ":attribute="This form will work
<ul class="menu" v-for="(item,index) in 4"> <li :class="{'selected':index===clickIndex}" @click="selected(index)"> <p> <h3>{{item}}点位标签</h3> <span style="margin: 15px 0px;">附近的资产:3个(2个未完成修订)</span><br /> <img :src="'img/'+(item+nameIndex)+'.jpg'" /> <a href="#" rel="external nofollow" ></a> </p> </li> </ul>
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
How to solve the file error after angularjs compression
How to use axios for cross-domain in vue deal with
The above is the detailed content of How to insert variable parameters in tag attributes in vue.js. For more information, please follow other related articles on the PHP Chinese website!