{"id":1045,"date":"2023-03-12T10:02:10","date_gmt":"2023-03-12T02:02:10","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1045"},"modified":"2023-04-29T12:41:20","modified_gmt":"2023-04-29T04:41:20","slug":"vue-discard-double-braces-for-html-attribute-difference-and-use-v-bind-instead","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/12\/vue-discard-double-braces-for-html-attribute-difference-and-use-v-bind-instead\/","title":{"rendered":"Vue\u8e29\u5751\uff1aHtml\u5c5e\u6027\u5dee\u503c\u5f03\u7528\u53cc\u5927\u62ec\u53f7\u6539\u7528v-bind"},"content":{"rendered":"<h3>input\u6807\u7b7e\u7684placeholder\u5c5e\u6027<\/h3>\n<pre><code class=\"language-html\">&lt;input slot=&quot;right&quot; type=&quot;number&quot; pattern=&quot;[0-9]*&quot; placeholder=&quot;{{phone_placeholder}}&quot; autocomplete=&quot;off&quot; v-model=&quot;user.phone&quot; \/&gt;<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u9519\u8bef\u63d0\u793a\uff1a<\/p>\n<pre><code>- placeholder=&quot;{{phone_placeholder}}&quot;: Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of &lt;div id=&quot;{{ val }}&quot;&gt;, use &lt;div :id=&quot;val&quot;&gt;.<\/code><\/pre>\n<p>&quot;placeholder&quot;\u5c5e\u6027\u63d2\u503c\u9519\u8bef\uff0c\u5982\u63d0\u793a\uff0c\u4f7f\u7528 <code>v-bind:placeholder<\/code> \u7b80\u5199\u4e3a <code>:placeholder<\/code> \u4ee3\u66ff\uff0c\u5373<\/p>\n<pre><code class=\"language-html\">&lt;input slot=&quot;right&quot; type=&quot;number&quot; pattern=&quot;[0-9]*&quot; :placeholder=&quot;phone_placeholder&quot; autocomplete=&quot;off&quot; v-model=&quot;user.phone&quot; \/&gt;<\/code><\/pre>\n<h3>img\u6807\u7b7e\u7684src\u5c5e\u6027<\/h3>\n<pre><code class=\"language-html\">&lt;div v-for=&quot;city in cityList&quot;&gt;\n  &lt;div&gt;\u57ce\u5e02\u540d\u79f0\uff1a{{item.title}}&lt;\/div&gt;\n  &lt;div&gt;\u57ce\u5e02ID\uff1a{{item.id}}&lt;\/div&gt;\n  &lt;div&gt;\u57ce\u5e02\u56fe\u7247\uff1a&lt;img src=&quot;{{item.img}}&quot;&gt;&lt;\/div&gt;  \/\/\u8fd9\u884c\u662f\u62a5\u9519\u7684\n&lt;\/div&gt;<\/code><\/pre>\n<p>\u5e94\u6539\u4e3a<\/p>\n<pre><code class=\"language-html\">&lt;div v-for=&quot;city in cityList&quot;&gt;\n  &lt;div&gt;\u57ce\u5e02\u540d\u79f0\uff1a{{city.title}}&lt;\/div&gt;\n  &lt;div&gt;\u57ce\u5e02ID\uff1a{{city.id}}&lt;\/div&gt;\n  &lt;div&gt;\u57ce\u5e02\u56fe\u7247\uff1a&lt;img :src=&quot;city.img&quot;&gt;&lt;\/div&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<h3>a\u6807\u7b7e\u7684href\u5c5e\u6027<\/h3>\n<p>href\u7684\u4e24\u79cd\u4f7f\u7528\uff1a<\/p>\n<pre><code class=\"language-html\">&lt;template&gt;\n  &lt;div&gt;\n    &lt;a :href=&#039;msg&#039;&gt;APP\u5f00\u53d1\u6280\u672f\u535a\u5ba2&lt;\/a&gt; \n    &lt;a href=&#039;http:\/\/www.appblog.cn&#039;&gt;APP\u5f00\u53d1\u6280\u672f\u535a\u5ba2&lt;\/a&gt; \n  &lt;\/div&gt;    \n&lt;\/template&gt;\n\n&lt;script&gt;\nexport default: {\n  data () {\n    return: {\n      msg: &#039;http:\/\/www.appblog.cn&#039;\n    }  \n  }\n}\n&lt;\/script&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>input\u6807\u7b7e\u7684placeholder\u5c5e\u6027 &lt;input slot=&quot;right&quot;  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[],"class_list":["post-1045","post","type-post","status-publish","format-standard","hentry","category-vue"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1045","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1045"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1045\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}