Home >Web Front-end >JS Tutorial >How to insert variable parameters in tag attributes in vue.js

How to insert variable parameters in tag attributes in vue.js

php中世界最好的语言
php中世界最好的语言Original
2018-03-28 17:00:361864browse

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="{&#39;selected&#39;:index===clickIndex}" @click="selected(index)">
                <p>
                  <h3>{{item}}点位标签</h3>
                  <span style="margin: 15px 0px;">附近的资产:3个(2个未完成修订)</span><br />
                  <img :src="&#39;img/&#39;+(item+nameIndex)+&#39;.jpg&#39;" />
                  <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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn