{"id":976,"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 \u8ba1\u7b97\u5c5e\u6027","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/976.html","title":{"rendered":"Vue.js \u8ba1\u7b97\u5c5e\u6027"},"content":{"rendered":"


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

\n

Vue.js \u8ba1\u7b97\u5c5e\u6027<\/h1>\n<\/p><\/div>\n
\n \u5728Vue.js\u4e2d\uff0c\u5f53\u6211\u4eec\u5fc5\u987b\u5904\u7406\u590d\u6742\u7684\u903b\u8f91\u548c\u8fd0\u7b97\u65f6\uff0c\u5c06\u4f7f\u7528\u8ba1\u7b97\u5c5e\u6027\u3002\u8ba1\u7b97\u5c5e\u6027\u5c31\u50cf\u65b9\u6cd5\u4e00\u6837\uff0c\u4f46\u6709\u4e00\u4e9b\u533a\u522b\u3002\n <\/div>\n
\n \u5728\u524d\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5df2\u6210\u529f\u4f7f\u7528\u6a21\u677f\u5185\u8868\u8fbe\u5f0f\u3002\u5b83\u4eec\u975e\u5e38\u65b9\u4fbf\uff0c\u4f46\u662f\u6a21\u677f\u5185\u8868\u8fbe\u5f0f\u4e3b\u8981\u7528\u4e8e\u7b80\u5355\u64cd\u4f5c\u3002\u5982\u679c\u60a8\u5fc5\u987b\u5728\u6a21\u677f\u4e2d\u6dfb\u52a0\u6c89\u91cd\u800c\u590d\u6742\u7684\u903b\u8f91\uff0c\u5219\u5b83\u53ef\u80fd\u4f1a\u80bf\u4e14\u96be\u4ee5\u7ef4\u62a4\u3002\n <\/div>\n
\n \u4f8b\u5982: <\/strong>\n <\/div>\n
\n
 <div id=\"example\"><\/span>
  {{ message.split('').reverse().join('') }}
<\/div><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u5728\u8fd9\u91cc\u60a8\u53ef\u4ee5\u770b\u5230\u6a21\u677f\u4e0d\u50cf\u4ee5\u524d\u90a3\u6837\u7b80\u5355\u548c\u58f0\u660e\u6027\u3002\u5b83\u770b\u8d77\u6765\u66f4\u52a0\u590d\u6742\uff0c\u60a8\u5fc5\u987b\u5148\u4ed4\u7ec6\u67e5\u770b\u4e00\u4e0b\uff0c\u7136\u540e\u624d\u80fd\u610f\u8bc6\u5230\u5b83\u4ee5\u76f8\u53cd\u7684\u65b9\u5f0f\u663e\u793a\u6d88\u606f\u3002\u5f53\u60a8\u5fc5\u987b\u5728\u6a21\u677f\u4e2d\u91cd\u590d\u4f7f\u7528\u53cd\u5411\u6d88\u606f\u65f6\uff0c\u6b64\u95ee\u9898\u53ef\u80fd\u4f1a\u53d8\u5f97\u66f4\u52a0\u4e25\u91cd\u3002\n <\/div>\n
\n \u8ba9\u6211\u4eec\u4e3e\u4e00\u4e9b\u7b80\u5355\u7684\u793a\u4f8b\u6765\u4f7f\u8ba1\u7b97\u5c5e\u6027\u7684\u6982\u5ff5\u6e05\u6670\u6613\u61c2\u3002\u8fd9\u4e5f\u4f7f\u60a8\u80fd\u591f\u51b3\u5b9a\u4f55\u65f6\u4f7f\u7528\u65b9\u6cd5\u4ee5\u53ca\u4f55\u65f6\u4f7f\u7528\u8ba1\u7b97\u5c5e\u6027\u3002\n <\/div>\n
\n \u8bf7\u53c2\u9605\u4ee5\u4e0b\u793a\u4f8b\u4ee5\u4e86\u89e3\u8ba1\u7b97\u5c5e\u6027\u7684\u6982\u5ff5:\n <\/div>\n

Example1 <\/p>\n

\n index.html\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 <html><\/span>
   <head><\/span>
      <title><\/span>Vue.js Computed Property<\/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=\"com_props\">
  This is the Original message:<h2><\/span> {{ message }}<\/h2><\/span>
  This is the Computed reversed message: <h2><\/span> {{ reversedMessage }}<\/h2><\/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: '#com_props',
  data: {
    message: 'Hello lidihuo'
  },
  computed: {
    \/\/ a computed getter
    reversedMessage: function () {
      \/\/ `this` points to the vm instance
      return this.message.split('').reverse().join('')
    }
  }
})
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684CSS\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

\u793a\u4f8b\u8bf4\u660e<\/h3>\n
\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u58f0\u660e\u4e86\u8ba1\u7b97\u5c5e\u6027
\n reversedMessage <\/strong>\u3002\u8fd9\u91cc\u63d0\u4f9b\u7684\u51fd\u6570\u7528\u4f5c\u5c5e\u6027reversedMessage\u7684\u83b7\u53d6\u51fd\u6570\u3002
\n reversedMessage <\/strong>\u7684\u503c\u59cb\u7ec8\u53d6\u51b3\u4e8e
\n message <\/strong>\u5c5e\u6027\u7684\u503c\u3002\n <\/div>\n
\n
 data: {
    message: 'Hello lidihuo'
  },
  computed: {
    \/\/ a computed getter
    reversedMessage: function () {
<\/span><\/code><\/pre>\n<\/p><\/div>\n

\u793a\u4f8b2 <\/h3>\n
\n \u518d\u4e3e\u4e00\u4e2a\u793a\u4f8b\u3002\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u60a8\u53ef\u4ee5\u5728\u8868\u5355\u7ed3\u6784\u4e2d\u8f93\u5165\u6570\u636e\u5e76\u67e5\u770b\u8ba1\u7b97\u673a\u5c5e\u6027\u7684\u7ed3\u679c\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 Computed Property<\/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 = \"com_props\">
         FirstName : <input type = \"text\" v-model = \"firstname\" \/> <br\/><br\/>
         LastName : <input type = \"text\" v-model = \"lastname\"\/> <br\/><br\/>
         <h2><\/span>My name is {{firstname}} {{lastname}}<\/h2><\/span>
         <h2><\/span>Retrieve name by using computed property : {{getfullname}}<\/h2><\/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: '#com_props',
   data: {
      firstname :\"\",
      lastname :\"\",
      birthyear : \"\"
   },
   computed :{
      getfullname : function(){
         return this.firstname +\" \"+ this.lastname;
      }
   }
})
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684CSS\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 \u8ba1\u7b97\u5c5e\u6027_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\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2a\u540d\u4e3a
\n \u540d\u5b57<\/strong>\u548c
\n \u59d3\u6c0f<\/strong>\u3002\u8fd9\u4e9b\u6587\u672c\u6846\u4f7f\u7528\u5c5e\u6027
\n firstname <\/strong>\u548c
\n lastname <\/strong>\u7ed1\u5b9a\u3002\n <\/div>\n
\n \u73b0\u5728\uff0c\u6211\u4eec\u8c03\u7528\u4e86\u8ba1\u7b97\u65b9\u6cd5getfullname\uff0c\u8be5\u65b9\u6cd5\u8fd4\u56de\u8f93\u5165\u7684\u540d\u5b57\u548c\u59d3\u6c0f\u3002\n <\/div>\n
\n
 computed :{
   getfullname : function(){
      return this.firstname +\" \"+ this.lastname;
   }
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u5f53\u6211\u4eec\u5728\u6587\u672c\u6846\u4e2d\u952e\u5165\u5185\u5bb9\u65f6\uff0c\u51fd\u6570\u5728\u5c5e\u6027\u7684\u540d\u5b57\u6216\u59d3\u6c0f\u66f4\u6539\u540e\u8fd4\u56de\u76f8\u540c\u7684\u503c\u3002\u56e0\u6b64\uff0c\u5728\u8ba1\u7b97\u7684\u5e2e\u52a9\u4e0b\uff0c\u6211\u4eec\u4e0d\u5fc5\u505a\u4efb\u4f55\u7279\u5b9a\u7684\u4e8b\u60c5\uff0c\u4f8b\u5982\u8bb0\u4f4f\u8981\u8c03\u7528\u4e00\u4e2a\u51fd\u6570\u3002\u6709\u4e86\u8ba1\u7b97\u5c5e\u6027\uff0c\u5b83\u4fbf\u4f1a\u4f5c\u4e3a\u66f4\u6539\u5185\u90e8\u4f7f\u7528\u7684\u5c5e\u6027(\u5373\u540d\u5b57\u548c\u59d3\u6c0f)\u672c\u8eab\u88ab\u8c03\u7528\u3002\n <\/div>\n

\u65b9\u6cd5\u4e0e\u8ba1\u7b97\u5c5e\u6027\u4e4b\u95f4\u7684\u533a\u522b<\/h3>\n
\n \u5728\u4ee5\u4e0a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4e86\u89e3\u4e86\u8ba1\u7b97\u5c5e\u6027\u3002\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u4e86\u89e3\u65b9\u6cd5\u548c\u8ba1\u7b97\u5c5e\u6027\u4e4b\u95f4\u7684\u533a\u522b\u3002\u6211\u4eec\u77e5\u9053\u8fd9\u4e24\u4e2a\u90fd\u662f\u5bf9\u8c61\uff0c\u5e76\u4e14\u5185\u90e8\u5b9a\u4e49\u4e86\u4e00\u4e9b\u51fd\u6570\uff0c\u8fd9\u4e9b\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u503c\u3002\n <\/div>\n
\n \u5bf9\u4e8e\u8ba1\u7b97\u5c5e\u6027\uff0c\u5bf9\u4e8e\u65b9\u6cd5\uff0c\u6211\u4eec\u5c06\u5176\u79f0\u4e3a\u5c5e\u6027\uff0c\u5bf9\u51fd\u6570\u800c\u8a00\uff0c\u5c06\u5176\u79f0\u4e3a\u51fd\u6570\u3002\u8ba9\u6211\u4eec\u770b\u4e00\u4e2a\u793a\u4f8b\uff0c\u4e86\u89e3\u65b9\u6cd5\u548c\u8ba1\u7b97\u5c5e\u6027\u4e4b\u95f4\u7684\u533a\u522b\u3002\n <\/div>\n
\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 <html><\/span>
   <head><\/span>
      <title><\/span>Vue.js Computed Property<\/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 = \"com_props\">
         <h2 style = \"background-color:gray;\">Random No from computed property: {{getrandomno}}<\/h2><\/span>
         <h2><\/span>Random No from method: {{getrandomno1()}}<\/h2><\/span>
         <h2 style = \"background-color:gray;\">Random No from computed property: {{getrandomno}}<\/h2><\/span>
         <h2 style = \"background-color:gray;\">Random No from computed property: {{getrandomno}}<\/h2><\/span>
         <h2><\/span>Random No from method: {{getrandomno1()}}<\/h2><\/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: '#com_props',
            data: {
               name : \"helloworld\"
            },
            methods: {
               getrandomno1 : function() {
                  return Math.random();
               }
            },
            computed :{
               getrandomno : function(){
                  return Math.random();
               }
            }
         })
<\/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 \u8ba1\u7b97\u5c5e\u6027_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c2\u5f20 <\/p>\n

\u793a\u4f8b\u8bf4\u660e<\/h3>\n
\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a
\n getrandomno1 <\/strong>\u548c\u51fd\u6570\u540d\u79f0\u4e3a
\n getrandomno <\/strong>\u7684\u8ba1\u7b97\u5c5e\u6027\u3002\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528
\n Math.random()<\/strong>\u6765\u83b7\u53d6\u968f\u673a\u6570\u5f62\u5f0f\u7684\u7ed3\u679c\u3002\u6211\u4eec\u591a\u6b21\u8c03\u7528\u4e86\u65b9\u6cd5\u548c\u8ba1\u7b97\u5c5e\u6027\u4ee5\u67e5\u770b\u5176\u533a\u522b\u3002\n <\/div>\n
\n \u5728\u8fd9\u91cc\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\uff0c\u4ece\u8ba1\u7b97\u5c5e\u6027\u8fd4\u56de\u7684\u968f\u673a\u6570\u6bcf\u6b21\u90fd\u4fdd\u6301\u4e0d\u53d8\uff0c\u800c\u4e0e\u88ab\u8c03\u7528\u7684\u6b21\u6570\u65e0\u5173\u3002 \u3002\u8fd9\u610f\u5473\u7740\u6bcf\u6b21\u8c03\u7528\u5b83\uff1b\u6700\u540e\u4e00\u4e2a\u503c\u5c06\u5168\u90e8\u66f4\u65b0\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u5bf9\u4e8e\u65b9\u6cd5\u6765\u8bf4\uff0c\u5b83\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u56e0\u6b64\u6bcf\u6b21\u8c03\u7528\u5b83\u90fd\u4f1a\u8fd4\u56de\u4e00\u4e2a\u4e0d\u540c\u7684\u503c\u3002\n <\/div>\n

Vue.js\u8ba1\u7b97\u5c5e\u6027\u4e2d\u7684\u83b7\u53d6\/\u8bbe\u7f6e<\/h3>\n
\n \u8ba9\u6211\u4eec\u770b\u770b\u5982\u4f55\u5728
\n Vue.js \u8ba1\u7b97\u5c5e\u6027\u4e2d\u4f7f\u7528get\/set\u51fd\u6570\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 Computed Property<\/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 = \"com_props\">
         <input type = \"text\" v-model = \"fullname\" \/>
         <h1><\/span>{{firstName}}<\/h1><\/span>
         <h1><\/span>{{lastName}}<\/h1><\/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: '#com_props',
            data: {
               firstName : \"Alex\",
               lastName : \"Junior\"
            },
            methods: {
            },
            computed :{
               fullname : {
                  get : function() {
                     return this.firstName+\" \"+this.lastName;
                  }
               }
            }
         })
<\/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 \u8ba1\u7b97\u5c5e\u6027_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c3\u5f20 <\/p>\n

\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u7ed1\u5b9a\u5230\u5168\u540d\u7684\u8ba1\u7b97\u5c5e\u6027\u8f93\u5165\u6846\u3002\u5b83\u8fd4\u56de\u4e00\u4e2a\u540d\u4e3aget\u7684\u51fd\u6570\u5e76\u7ed9\u51fa\u5168\u540d\u4f5c\u4e3a\u8f93\u51fa\uff0c\u5373\u540d\u5b57\u548c\u59d3\u6c0f\u3002\n <\/div>\n
\n
 <h1><\/span>{{firstName}}<\/h1><\/span>
<h1><\/span>{{lastName}}<\/h1><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\uff0c\u5982\u679c\u60a8\u5728\u6587\u672c\u6846\u4e2d\u66f4\u6539\u540d\u79f0\uff0c\u7ed3\u679c\u5c06\u4e0d\u4f1a\u53cd\u6620\u5728\u8f93\u51fa\u4e2d\u3002\u53c2\u89c1\u4e0b\u56fe\u3002\n <\/div>\n
\n \u8f93\u51fa: <\/strong>\n <\/div>\n

Vue.js \u8ba1\u7b97\u5c5e\u6027_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c4\u5f20 <\/p>\n

\n \u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u6211\u4eec\u5fc5\u987b\u5728\u5168\u540d\u8ba1\u7b97\u5c5e\u6027\u4e2d\u6dfb\u52a0
\n setter\u51fd\u6570<\/strong>\u3002\n <\/div>\n
\n \u5728\u5168\u540d\u4e2d\u6dfb\u52a0\u4ee5\u4e0bset\u51fd\u6570\u8ba1\u7b97\u5c5e\u6027:\n <\/div>\n
\n
 computed :{
   fullname : {
      get : function() {
         return this.firstName+\" \"+this.lastName;
      },
      set : function(name) {
         var fname = name.split(\"\");
         this.firstName = fname[0];
         this.lastName = fname[1]
      }
   }
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \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 Computed Property<\/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 = \"com_props\">
         <input type = \"text\" v-model = \"fullname\" \/>
         <h1><\/span>{{firstName}}<\/h1><\/span>
         <h1><\/span>{{lastName}}<\/h1><\/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: '#com_props',
            data: {
               firstName : \"Alex\",
               lastName : \"Junior\"
            },
            methods: {
            },
            computed :{
               fullname : {
                  get : function() {
                     return this.firstName+\" \"+this.lastName;
                  },
                  set : function(name) {
                     var fname = name.split(\"\");
                     this.firstName = fname[0];
                     this.lastName = fname[1]
                  }
               }
            }
         });
<\/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 \u8ba1\u7b97\u5c5e\u6027_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c5\u5f20 <\/p>\n

\n \u73b0\u5728\uff0c\u5982\u679c\u5728\u8fd0\u884c\u4ee3\u7801\u540e\u7f16\u8f91\u6587\u672c\u6846\uff0c\u5219\u66f4\u65b0\u7684\u540d\u79f0\u5c06\u663e\u793a\u5728\u6d4f\u89c8\u5668\u3002\u7531\u4e8e
\n \u8bbe\u7f6e\u529f\u80fd<\/strong>\uff0c\u6b64\u5904\u7684\u540d\u5b57\u548c\u59d3\u6c0f\u5df2\u66f4\u65b0\u3002 get\u51fd\u6570\u8fd4\u56de\u540d\u5b57\u548c\u59d3\u6c0f\uff0c\u800cset\u51fd\u6570\u5219\u5728\u6587\u672c\u6846\u4e2d\u8fdb\u884c\u4efb\u4f55\u7f16\u8f91\u65f6\u5bf9\u5176\u8fdb\u884c\u66f4\u65b0\u3002\n <\/div>\n
\n \u7f16\u8f91\u540e\u67e5\u770b\u8f93\u51fa\u3002\n <\/div>\n
\n \u8f93\u51fa: <\/strong>\n <\/div>\n

Vue.js \u8ba1\u7b97\u5c5e\u6027_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c6\u5f20 <\/p>\n


\n

<\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"Vue.js \u8ba1\u7b97\u5c5e\u6027zh-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-976","post","type-post","status-publish","format-standard","hentry","category-vuejc"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/976"}],"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=976"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/976\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}