Home > Web Front-end > Vue.js > How to insert variables in vuejs

How to insert variables in vuejs

藏色散人
Release: 2021-10-27 14:39:21
Original
2986 people have browsed it

Vuejs method of inserting variable parameters: 1. Open the corresponding js code; 2. Through "

  • " method to insert variable parameters.
  • How to insert variables in vuejs

    The operating environment of this article: Windows 7 system, Vue version 2.9.6, Dell G3 computer.

    How to insert variables in vuejs?

    vue.js inserts variable parameters into tag attributes:

    html tag attributes, such as id, class, href, need to dynamically pass parameters and splice them String, I checked some information, but did not find a suitable solution. After thinking about it all morning, I finally tried the method:

    How to insert variables in vuejs

    v-bind: attribute = " ' String 'Custom variable name", I tried it myself and it worked fine. Friends in need can learn from it!

    Finally, you need to 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)">
                                    <div>
                                        <h3>{{item}}点位标签</h3>
                                        <span style="margin: 15px 0px;">附近的资产:3个(2个未完成修订)</span><br />
                                        <img  :src="&#39;img/&#39;+(item+nameIndex)+&#39;.jpg&#39;" / alt="How to insert variables in vuejs" >
                                        <a href="#"></a>
                                    </div>
                                </li>
           </ul>
    Copy after login

    Recommendation: "The latest 5 vue.js video tutorial selections

    The above is the detailed content of How to insert variables in vuejs. For more information, please follow other related articles on the PHP Chinese website!

    Related labels:
    source:php.cn
    Statement of this Website
    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
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template