Home > php教程 > PHP开发 > body text

Analysis of the causes of syntax errors in binding HTML class arrays in Vue.js

高洛峰
Release: 2016-12-09 15:58:16
Original
1415 people have browsed it

Vue.js has a syntax error in binding HTML class array, the details are as follows:

I found an error like this on the official website tutorial yesterday, see the picture below

http://cn.vuejs.org/guide/class -and-style.html

This is a bit cumbersome to write when there are multiple conditional classes. In 1.0.19+, object syntax can be used in array syntax:

If written like this, it can be executed successfully, but there is an error

data: {
classA: 'class-a',
classB: 'class-b',
classC: 'class-c',
isB: true,
isC: false
}
<div :class="[classA, { classB: isB, classC: isC }]">
Copy after login

is rendered as:

<div class="class-a classB">
Copy after login

If it is short Class-b such as horizontal characters is unsuccessful, so we still need to use standard object syntax with quotation marks

<div :class="[classA, { &#39;class-b&#39;: isB, &#39;class-c&#39;: isC }]">
Copy after login

Rendered as:

<div class="class-a class-b">
Copy after login


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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!