Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand the v-bind attribute of Vue

Shulou Source: shulou.com Published: 2022-06-02 17:12:52 10月04日 Update

This article mainly explains "how to understand the v-bind attributes of Vue". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to understand the v-bind attributes of Vue".

First, let's learn about the commonly used v-bind attribute, which uses the value of the variable defined in vue in the attribute.

Baidu Search

Var v = new Vue ({

El: "# div1", / / valid range of vue. You cannot use body directly.

Data: {/ / vue data required by the page

Href: "https://www.baidu.com"

}

});

Well, it's simple, so what if you need to display text with variables?

View

Var v = new Vue ({

El: "# div1", / / valid range of vue. You cannot use body directly.

Data: {/ / vue data required by the page

Id: 3

}

});

I see, you need to concatenate strings, like v-bind: can be abbreviated to: I'll try it in the next example.

Next I'll try the style binding.

Var v = new Vue ({

El: "# div1", / / valid range of vue. You cannot use body directly.

Data: {/ / vue data required by the page

ShowStyle: false

}

});

Yes, it can really be abbreviated, and the style binding seems to be a little different from other ones.

What about the binding of events?

It turns out that v-on is used to bind event operations, and you can also use @ instead of v-on.

Var v = new Vue ({

El: "# div1", / / valid range of vue. You cannot use body directly.

Data: {/ / vue data required by the page

BtnValue: "Click"

}

Methods: {/ / functions of vue available to the page

Fn1: function () {

Alert (this.msg)

}

Fn2: function () {

This.btnValue = "Click"

}

}

});

Thank you for your reading, the above is the content of "how to understand the v-bind attribute of Vue". After the study of this article, I believe you have a deeper understanding of how to understand the v-bind attribute of Vue. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Properties pages valid data scope learning events content variables styles abbreviations yes so it is and then functions examples functions characters strings that is. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL OPPO Reno Docker Microsoft vpn