{"id":979,"date":"2023-03-23T22:41:43","date_gmt":"2023-03-23T14:41:43","guid":{"rendered":""},"modified":"2023-03-23T22:41:43","modified_gmt":"2023-03-23T14:41:43","slug":"Vue.js \u6570\u636e\u7ed1\u5b9a","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/979.html","title":{"rendered":"Vue.js \u6570\u636e\u7ed1\u5b9a"},"content":{"rendered":"


\n <\/head>
\n <\/p>\n

\n

Vue.js \u6570\u636e\u7ed1\u5b9a<\/h1>\n<\/p><\/div>\n
\n Vue.js\u652f\u6301\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u7ed1\u5b9a\u3002\u5728\u5b66\u4e60Vue.js\u4e2d\u7684\u6570\u636e\u7ed1\u5b9a\u4e4b\u524d\uff0c\u8ba9\u6211\u4eec\u770b\u4e00\u4e0b\u4ec0\u4e48\u662f\u6570\u636e\u7ed1\u5b9a\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u5b83\u3002\n <\/div>\n

\u4ec0\u4e48\u662f\u6570\u636e\u7ed1\u5b9a\uff1f<\/h3>\n
\n \u6570\u636e\u7ed1\u5b9a\u662f\u4e00\u79cd\u7528\u4e8e\u5c06\u63d0\u4f9b\u8005\u548c\u4f7f\u7528\u8005\u7684\u6570\u636e\u6e90\u7ed1\u5b9a\u5728\u4e00\u8d77\u5e76\u5728\u68c0\u7d22\u65f6\u8fdb\u884c\u540c\u6b65\u7684\u6280\u672f\u3002\u5728\u6570\u636e\u7ed1\u5b9a\u8fc7\u7a0b\u4e2d\uff0c\u6bcf\u5f53\u66f4\u6539\u6570\u636e\u65f6\uff0c\u6570\u636e\u4fbf\u4f1a\u81ea\u52a8\u901a\u8fc7\u7ed1\u5b9a\u5230\u6570\u636e\u7684\u5143\u7d20\u53cd\u6620\u51fa\u6765\u3002\n <\/div>\n
\n \u672f\u8bed\u6570\u636e\u7ed1\u5b9a\u4e5f\u7528\u4e8e\u5143\u7d20\u4e2d\u6570\u636e\u7684\u5916\u90e8\u8868\u793a\u53d1\u751f\u53d8\u5316\u7684\u60c5\u51b5\uff0c\u5e76\u81ea\u52a8\u66f4\u65b0\u57fa\u7840\u6570\u636e\u4ee5\u53cd\u6620\u6b64\u66f4\u6539\u3002\n <\/div>\n

Vue.js class\u548c\u6837\u5f0f\u7ed1\u5b9a<\/h3>\n
\n \u5728
\n Vue.js \u6570\u636e\u7ed1\u5b9a\uff0c\u6211\u4eec\u5fc5\u987b\u64cd\u7eb5\u5143\u7d20\u7684\u7c7b\u5217\u8868\u548c\u5185\u8054\u6837\u5f0f\u3002\u6211\u4eec\u5df2\u7ecf\u77e5\u9053\u7c7b\u5217\u8868\u548c\u5185\u8054\u6837\u5f0f\u662f\u5c5e\u6027\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528
\n v-bind <\/strong>\u6765\u5904\u7406\u5b83\u4eec\u3002\u5f53\u6211\u4eec\u5c06v-bind\u4e0e\u7c7b\u548c\u6837\u5f0f\u4e00\u8d77\u4f7f\u7528\u65f6\uff0cVue.js\u63d0\u4f9b\u4e86\u7279\u6b8a\u7684\u589e\u5f3a\u529f\u80fd\u3002\u8868\u8fbe\u5f0f\u8fd8\u53ef\u4ee5\u4e0e\u5b57\u7b26\u4e32\u4e00\u8d77\u6c42\u503c\u5230\u5bf9\u8c61\u6216\u6570\u7ec4\u3002\n <\/div>\n
\n \u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u5b66\u4e60\u5982\u4f55\u5728Vue.js\u7ed1\u5b9a\u7684\u5e2e\u52a9\u4e0b\u64cd\u4f5c\u6216\u4e3aHTML\u5c5e\u6027\u5206\u914d\u503c\uff0c\u66f4\u6539\u6837\u5f0f\u4ee5\u53ca\u5206\u914d\u7c7b\u3002\u6307\u4ee4v-bind\u3002\u8ba9\u6211\u4eec\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u4ee5\u4e86\u89e3\u4e3a\u4ec0\u4e48\u548c\u4f55\u65f6\u4f7f\u7528v-bind\u6307\u4ee4\u8fdb\u884c\u6570\u636e\u7ed1\u5b9a\u3002\n <\/div>\n
\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 <html><\/span>
   <head><\/span>
      <title><\/span>Vue.js Data Binding<\/title><\/span>
      <link rel=\"stylesheet\" href=\"index.css\">
        <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
    <\/head><\/span>
    <body><\/span>
      <div id = \"databinding\">
         <h3><\/span>{{title}}<\/h3><\/span>
         <a href = \"hreflink\" target = \"_blank\"> Click Here <\/a><\/span> <br\/>
         <a href = \"{{hreflink}}\" target = \"_blank\">Click Here <\/a><\/span> <br\/>
         <a v-bind:href = \"hreflink\" target = \"_blank\">Click Here <\/a><\/span> <br\/>
      <\/div><\/span>
      <script src=\"index.js\"><\/script><\/span>
   <\/body><\/span>
<\/html><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 var vm = new Vue({
            el: '#databinding',
            data: {
               title : \"Data Binding Simple Example\",
               hreflink : \"https:\/\/www.lidihuo.com\"
            }
         })
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8ba9\u6211\u4eec\u4f7f\u7528\u7b80\u5355\u7684
\n CSS \u6587\u4ef6\u4f7f\u8f93\u51fa\u66f4\u5177\u5438\u5f15\u529b\u3002\n <\/div>\n
\n Index.css\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 html, body {
    margin: 5px;
    padding: 0;
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u7a0b\u5e8f\u6267\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n
\n \u8f93\u51fa: <\/strong>\n <\/div>\n

Vue.js \u6570\u636e\u7ed1\u5b9a_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c1\u5f20 <\/p>\n

\u793a\u4f8b\u8bf4\u660e<\/h3>\n
\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u6807\u9898\u53d8\u91cf\u548c\u4e09\u4e2a\u951a\u94fe\u63a5\u5982\u4e0b:\n <\/div>\n
\n
 <h3><\/span>{{title}}<\/h3><\/span>
<a href = \"hreflink\" target = \"_blank\"> Click Here <\/a><\/span> <br\/>
<a href = \"{{hreflink}}\" target = \"_blank\">Click Here <\/a><\/span> <br\/>
<a v-bind:href = \"hreflink\" target = \"_blank\">Click Here <\/a><\/span> <br\/>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6211\u4eec\u8fd8\u4e3a\u6570\u636e\u5bf9\u8c61\u4e2d\u7684href\u5206\u914d\u4e86\u4e00\u4e2a\u503chreflink:
\n \" https:\/\/www.lidihuo.com\" <\/strong>\u3002\n <\/div>\n

\u5982\u679c\u60a8\u5355\u51fb\u7b2c\u4e00\u4e2a\"\u5355\u51fb\u6b64\u5904\"\u94fe\u63a5\uff0c\u5219\u8be5href\u4f1a\u663e\u793a\u4e3ahreflink\uff0c\u56e0\u6b64\u4e0d\u4f1a\u91cd\u5b9a\u5411\u5230\u76ee\u6807\u7f51\u5740\u3002<\/span>
\n \u5982\u679c\u60a8\u5355\u51fb\u7b2c\u4e8c\u4e2a\"\u5355\u51fb\u6b64\u5904\"\u94fe\u63a5\uff0c\u5219href\u4f1a\u663e\u793a\u4e3a{{hreflink}}\uff0c\u56e0\u6b64\u4e5f\u4e0d\u4f1a\u91cd\u5b9a\u5411\u5230\u76ee\u6807URL\u3002<\/span>
\n \u53ea\u6709\u7b2c\u4e09\u4e2a\u4f1a\u91cd\u5b9a\u5411\u6b63\u786e\u7684\u76ee\u6807URL\uff0c\u56e0\u4e3a\u6211\u4eec\u5fc5\u987b\u5c06\u5176\u4e0e v-bind\u6307\u4ee4<\/strong>\u7ed1\u5b9a\u3002\u8bf7\u53c2\u9605\u4ee5\u4e0b\u7ed3\u679c\u3002<\/span> <\/p>\n

\n \u56e0\u6b64\uff0c\u8981\u4e3aHTML\u5c5e\u6027\u5206\u914d\u503c\uff0c\u5c06\u5176\u4e0ev-bind\u6307\u4ee4\u7ed1\u5b9a\uff0c\u5982\u4e0b\u6240\u793a:\n <\/div>\n
\n
 <a v-bind:href = \"hreflink\" target = \"_blank\">Click Here<\/a><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528\u7b80\u5199\u5f62\u5f0f\u5305\u62ecv-bind\u6307\u4ee4\uff0c\u5982\u4e0b\u6240\u793a:\n <\/div>\n
\n
 <a :href = \"hreflink\" target = \"_blank\">Click Here<\/a><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6ce8\u610f: <\/span>\u5982\u679c\u60a8\u68c0\u67e5\u7ed3\u679c\u7684\u5143\u7d20\uff0c\u60a8\u5c06\u770b\u5230anchor\u6807\u7b7e\u672a\u663e\u793av-bind\u5c5e\u6027\u3002\u5b83\u663e\u793a\u7eafHTML\u3002\u5f53\u6211\u4eec\u68c0\u67e5DOM\u65f6\uff0c\u53ef\u4ee5\u770b\u5230Vue.js\u5c5e\u6027\u3002\n <\/div>\n

Vue.js HTML\u7c7b\u7ed1\u5b9a<\/h3>\n
\n \u5728Vue.js\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u7ed1\u5b9a
\n HTML \u7c7b\uff0c\u65b9\u6cd5\u662f\u4f7f\u7528v-bind: class\u6307\u4ee4\u3002\u8ba9\u6211\u4eec\u770b\u4e00\u4e2a\u793a\u4f8b\u6765\u6f14\u793aVue.js\u4e2dHTML\u7c7b\u7684\u7ed1\u5b9a\u3002\n <\/div>\n
\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 <html><\/span>
   <head><\/span>
      <title><\/span>Vue.js Data Binding<\/title><\/span>
      <link rel=\"stylesheet\" href=\"index.css\">
        <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
    <\/head><\/span>
    <body><\/span>
      <style><\/span>
         .active {
            background: skyblue;
         }
      <\/style><\/span>
      <div id = \"classbinding\">
         <div v-bind:class = \"{active:isactive}\"><b><\/span>{{title}}<\/b><\/span><\/div><\/span>
      <\/div><\/span>
      <script src=\"index.js\"><\/script><\/span>
   <\/body><\/span>
<\/html><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 var vm = new Vue({
            el: '#classbinding',
            data: {
               title : \"HTML class binding example\",
               isactive : true
            }
         })
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u7a0b\u5e8f\u6267\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n
\n \u8f93\u51fa: <\/strong>\n <\/div>\n

Vue.js \u6570\u636e\u7ed1\u5b9a_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c2\u5f20 <\/p>\n

\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528
\n v-bind\u521b\u5efa\u4e86\u4e00\u4e2adiv: class =\"{active: isactive}\" <\/strong>\u3002\u5728\u8fd9\u91cc\uff0c
\n \u4e0d\u6d3b\u52a8<\/strong>\u662f\u57fa\u4e8e\u6b63\u786e\u6216\u9519\u8bef\u503c\u7684\u53d8\u91cf\u3002\u8fd9\u4e2aisactive\u53d8\u91cf\u7528\u4e8e\u5c06class active\u5e94\u7528\u4e8ediv\u3002\u5f53\u6211\u4eec\u5c06isactive\u53d8\u91cf\u5206\u914d\u4e3atrue\u65f6\uff0c\u5b83\u5c06\u663e\u793a\u6211\u4eec\u5728.active\u6837\u5f0f\u4e2d\u5b9a\u4e49\u7684\u7ed3\u679c\u4e2d\u6307\u5b9a\u7684\u6837\u5f0f\uff0c\u80cc\u666f\u989c\u8272\u4e3a\u5929\u84dd\u8272\u3002 >\u4e3a\u5047\uff0c\u5b83\u5c06\u4e0d\u4f1a\u5728\u7ed3\u679c\u4e2d\u5e94\u7528\u6307\u5b9a\u7684\u6837\u5f0f\u3002\n <\/div>\n
\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 var vm = new Vue({
            el: '#classbinding',
            data: {
               title : \"HTML class binding example\",
               isactive : false
            }
         })
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u7a0b\u5e8f\u6267\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n
\n \u8f93\u51fa: <\/strong>\n <\/div>\n

Vue.js \u6570\u636e\u7ed1\u5b9a_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c3\u5f20 <\/p>\n

\u5c06\u591a\u4e2a\u7c7b\u5206\u914d\u7ed9HTML\u6807\u7b7e<\/h3>\n
\n \u60a8\u8fd8\u53ef\u4ee5\u5c06\u591a\u4e2a\u7c7b\u5206\u914d\u7ed9HTML\u6807\u7b7ev-bind\u5c5e\u6027\u7684\u4f7f\u7528\u3002\u8bf7\u53c2\u89c1\u4ee5\u4e0b\u793a\u4f8b:\n <\/div>\n
\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 <html><\/span>
   <head><\/span>
      <title><\/span>Vue.js Data Binding<\/title><\/span>
      <link rel=\"stylesheet\" href=\"index.css\">
        <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
    <\/head><\/span>
    <body><\/span>
      <style><\/span>
         .info {
            color: #00529B;
            background-color: #BDE5F8;
         }
         div {
            margin: 10px 0;
            padding: 12px;
         }
         .active {
            color: #4F8A10;
            background-color: #DFF2BF;
         }
         .displayError{
            color: #D8000C;
            background-color: #FFBABA;
         }
      <\/style><\/span>
      <div id = \"classbinding\">
         <div class = \"info\" v-bind:class = \"{ active: isActive, 'displayError': hasError }\">
            {{title}}
         <\/div><\/span>
      <\/div><\/span>
      <script src=\"index.js\"><\/script><\/span>
   <\/body><\/span>
<\/html><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 var vm = new Vue({
            el: '#classbinding',
            data: {
               title : \"HTML multiple class binding example\",
               isActive : false,
               hasError : false
            }
         })
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u7a0b\u5e8f\u6267\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n
\n \u8f93\u51fa: <\/strong>\n <\/div>\n

Vue.js \u6570\u636e\u7ed1\u5b9a_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c4\u5f20 <\/p>\n

\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u4ec5\u5e94\u7528\u4e86\u666e\u901a\u7c7b\u3002\u76ee\u524d\u5176\u4ed6\u4e24\u4e2a\u53d8\u91cf\u5747\u4e3a\u5047\u3002\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u770b\u770b\u5c06
\n isActive <\/strong>\u53d8\u91cf\u8bbe\u7f6e\u4e3a
\n true <\/strong>\u65f6\u4f1a\u53d1\u751f\u4ec0\u4e48:\n <\/div>\n
\n
 var vm = new Vue({
            el: '#classbinding',
            data: {
               title : \"HTML multiple class binding example\",
               isActive : true,
               hasError : false
            }
         })
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa: <\/strong>\n <\/div>\n

Vue.js \u6570\u636e\u7ed1\u5b9a_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c5\u5f20 <\/p>\n

\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4e3adiv\u5206\u914d\u4e86\u4e24\u4e2a\u7c7b\uff0c\u5373info\u548cactive\u3002\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u4f7f
\n hasError <\/strong>\u53d8\u91cf
\n true <\/strong>\u548c
\n isActive false <\/strong>\uff0c\u7136\u540e\u67e5\u770b\u7ed3\u679c\u3002\n <\/div>\n
\n
 var vm = new Vue({
            el: '#classbinding',
            data: {
               title : \"HTML multiple class binding example\",
               isActive : false,
               hasError : true
            }
         })
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa: <\/strong>\n <\/div>\n

Vue.js \u6570\u636e\u7ed1\u5b9a_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c6\u5f20 <\/p>\n

\n \u73b0\u5728\uff0c\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0cinfo\u548cdisplayError\u7c7b\u5e94\u7528\u4e8ediv\u3002\u8fd9\u6837\u4fbf\u53ef\u4ee5\u6839\u636e\u6761\u4ef6\u5e94\u7528\u591a\u4e2a\u7c7b\u3002\n <\/div>\n

\u4f7f\u7528\u6570\u7ec4\u5206\u914d\u591a\u4e2a\u7c7b<\/h3>\n
\n \u6211\u4eec\u8fd8\u53ef\u4ee5\u5c06\u7c7b\u4f5c\u4e3a\u6570\u7ec4\u4f20\u9012\u3002\u8bf7\u53c2\u89c1\u4e0b\u9762\u7684\u793a\u4f8b\u4ee5\u5f88\u597d\u5730\u7406\u89e3\u8fd9\u4e00\u70b9:\n <\/div>\n
\n \u8bed\u6cd5: <\/strong>\n <\/div>\n
\n
 <div v-bind:class=\"[activeClass, errorClass]\"><\/div><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u793a\u4f8b: <\/strong>\n <\/div>\n
\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 <html><\/span>
   <head><\/span>
      <title><\/span>Vue.js Data Binding<\/title><\/span>
      <link rel=\"stylesheet\" href=\"index.css\">
        <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
    <\/head><\/span>
    <body><\/span>
       <style><\/span>
         .info {
            color: #00529B;
            background-color: #BDE5F8;
         }
         div {
            margin: 10px 0;
            padding: 12px;
            font-size : 25px;
         }
         .active {
            color: #4F8A10;
            background-color: #DFF2BF;
         }
         .displayError{
            color: #D8000C;
            background-color: #FFBABA;
         }
      <\/style><\/span>
      <div id = \"classbinding\">
         <div v-bind:class = \"[infoclass, errorclass]\">{{title}}<\/div><\/span>
      <\/div><\/span>
      <script src=\"index.js\"><\/script><\/span>
   <\/body><\/span>
<\/html><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 var vm = new Vue({
            el: '#classbinding',
            data: {
               title : \"Multiple classes with array example\",
               infoclass : 'info',
               errorclass : 'displayError'
            }
         })
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u7a0b\u5e8f\u6267\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n
\n \u8f93\u51fa: <\/strong>\n <\/div>\n

Vue.js \u6570\u636e\u7ed1\u5b9a_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c7\u5f20 <\/p>\n

\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u4e24\u4e2a\u7c7b\u5747\u5e94\u7528\u4e8ediv\u3002\n <\/div>\n

Vue.js\u5185\u8054\u6837\u5f0f\u7ed1\u5b9a<\/h3>\n
\n \u5bf9\u8c61\u8bed\u6cd5<\/strong>\n <\/div>\n
\n v-bind: style <\/strong>\u7684\u5bf9\u8c61\u8bed\u6cd5\u7c7b\u4f3c\u4e8e
\n CSS \uff0c\u4f46\u8fd9\u662f
\n JavaScript \u76ee\u7684\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528camelCase\u6216kebab-case(\u5728kebab-case\u4e2d\u4f7f\u7528\u5f15\u53f7)\u4f5c\u4e3aCSS\u5c5e\u6027\u540d\u79f0:\n <\/div>\n
\n HTML: <\/strong>\n <\/div>\n
\n
 <div v-bind:style=\"{ color: activeColor, fontSize: fontSize + 'px' }\"><\/div><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n CSS: <\/strong>\n <\/div>\n
\n
 data: {
  activeColor: 'red',
  fontSize: 30
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u60a8\u8fd8\u53ef\u4ee5\u76f4\u63a5\u7ed1\u5b9a\u6837\u5f0f\u5bf9\u8c61\u4ee5\u4f7f\u6a21\u677f\u66f4\u6574\u6d01\u3002\n <\/div>\n
\n HTML: <\/strong>\n <\/div>\n
\n
 <div v-bind:style=\"styleObject\"><\/div><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n CSS: <\/strong>\n <\/div>\n
\n
 data: {
  styleObject: {
    color: 'red',
    fontSize: '30px'
  }
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8ba9\u6211\u4eec\u4e3e\u4e2a\u4f8b\u5b50\u6765\u6e05\u695a\u5730\u7406\u89e3\u8fd9\u4e2a\u6982\u5ff5\u3002\n <\/div>\n
\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 <html><\/span>
   <head><\/span>
      <title><\/span>Vue.js Data Binding<\/title><\/span>
      <link rel=\"stylesheet\" href=\"index.css\">
        <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
    <\/head><\/span>
    <body><\/span>
      <div id = \"databinding\">
         <div v-bind:style = \"{ color: activeColor, fontSize: fontSize + 'px' }\">{{title}}<\/div><\/span>
      <\/div><\/span>
      <script src=\"index.js\"><\/script><\/span>
   <\/body><\/span>
<\/html><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 var vm = new Vue({
            el: '#databinding',
            data: {
               title : \"Inline style Binding Example\",
               activeColor: 'red',
               fontSize :'30'
            }
         })
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u7a0b\u5e8f\u6267\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n
\n \u8f93\u51fa: <\/strong>\n <\/div>\n

Vue.js \u6570\u636e\u7ed1\u5b9a_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c8\u5f20 <\/p>\n

\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u60a8\u53ef\u4ee5\u770b\u5230div\u5e94\u7528\u4e86\u6837\u5f0f\uff0c\u5e76\u4e14\u4ece\u6570\u636e\u5bf9\u8c61\u4e2d\u83b7\u53d6\u4e86\u6570\u636e\u3002\n <\/div>\n
\n \u60a8\u53ef\u4ee5\u901a\u8fc7\u5c06\u6240\u6709\u503c\u5206\u914d\u7ed9\u53d8\u91cf\uff0c\u7136\u540e\u5c06\u53d8\u91cf\u5206\u914d\u7ed9div\u6765\u83b7\u53d6\u76f8\u540c\u7684\u7ed3\u679c\u3002\n <\/div>\n
\n \u793a\u4f8b: <\/strong>\n <\/div>\n
\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 <html><\/span>
   <head><\/span>
      <title><\/span>Vue.js Data Binding<\/title><\/span>
      <link rel=\"stylesheet\" href=\"index.css\">
        <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
    <\/head><\/span>
    <body><\/span>
      <div id = \"databinding\">
         <div v-bind:style = \"styleobj\">{{title}}<\/div><\/span>
      <\/div><\/span>
      <script src=\"index.js\"><\/script><\/span>
   <\/body><\/span>
<\/html><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 var vm = new Vue({
            el: '#databinding',
            data: {
               title : \"Inline style Binding Example-2\",
               styleobj : {
                  color: 'red',
                  fontSize :'30px'
               }
            }
         })
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa: <\/strong>\n <\/div>\n

Vue.js \u6570\u636e\u7ed1\u5b9a_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c9\u5f20 <\/p>\n

\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u989c\u8272\u548cfontSize\u88ab\u5206\u914d\u7ed9\u540d\u4e3astyleobj\u7684\u5bf9\u8c61\uff0c\u800c\u76f8\u540c\u7684\u5bf9\u8c61\u88ab\u5206\u914d\u7ed9div\u3002\n <\/div>\n
\n

<\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"Vue.js \u6570\u636e\u7ed1\u5b9azh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[122],"tags":[],"class_list":["post-979","post","type-post","status-publish","format-standard","hentry","category-vuejc"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/979"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=979"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/979\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}