{"id":652,"date":"2021-08-27T17:14:50","date_gmt":"2021-08-27T09:14:50","guid":{"rendered":"http:\/\/blog.viter.top\/?p=652"},"modified":"2021-08-27T17:15:50","modified_gmt":"2021-08-27T09:15:50","slug":"%e9%9d%9e-prop-%e7%9a%84-attribute","status":"publish","type":"post","link":"https:\/\/blog.viter.top\/index.php\/2021\/08\/27\/%e9%9d%9e-prop-%e7%9a%84-attribute\/","title":{"rendered":"\u975e Prop \u7684 Attribute"},"content":{"rendered":"\n<p>App.vue<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;props-test\n    id=\"sss\"\n    :data-show=\"'activated'\"\n    @change=\"showChange\"\n    msg1=\"msg-ssss\"\n    msg2=\"msg-aaaa\"\n  &gt;&lt;\/props-test&gt;<\/code><\/pre>\n\n\n\n<p>PropsTest.vue<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;\n  &lt;div&gt;\n    &lt;!-- &lt;div class=\"propsTest\" :=\"$attrs\" @click=\"changePros\"&gt;data-status=\"activated\"&lt;\/div&gt;\n    \n    &lt;input type=\"datetime-local\" :=\"$attrs\" \/&gt; --&gt;\n    &lt;!-- &lt;div&gt;\n      &lt;select&gt;\n        &lt;option value=\"1\"&gt;Yesterday&lt;\/option&gt;\n        &lt;option value=\"2\"&gt;Today&lt;\/option&gt;\n        &lt;option value=\"3\"&gt;Tomorrow&lt;\/option&gt;\n      &lt;\/select&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;input type=\"text\" \/&gt;\n    &lt;\/div&gt; --&gt;\n    &lt;header&gt;header&lt;\/header&gt;\n    &lt;main v-bind=\"$attrs\"&gt;main&lt;\/main&gt;\n    &lt;footer&gt;footer&lt;\/footer&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n\n&lt;script&gt;\nimport { toRaw } from 'vue';\nexport default {\n  name: 'PropsTest',\n  \/\/ inheritAttrs: false,\n  props: &#91;'msg1', 'msg2'],\n  setup(props) {\n    console.log('props', props);\n    \n    const changePros = (e) =&gt; {\n      \/\/ console.log('e-changePros',e.target.attributes&#91;'data-v'].value);\n      console.log('e-changePros',e);      \n    }\n    return {\n      changePros\n    }\n  },\n  created() {\n    console.log(\"this.$attrs\", this.$attrs);\n    console.log(\"toRaw---this.$attrs\", toRaw(this.$attrs));\n  },\n};\n&lt;\/script&gt;\n\n&lt;style lang=\"scss\" scoped&gt;\n.propsTest {\n  color: red;\n}\n\/\/ &#91;data-show=activated] {\n\/\/   display: none;\n\/\/ }\n&lt;\/style&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>App.vue PropsTest.vue<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[9,10],"_links":{"self":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts\/652"}],"collection":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/comments?post=652"}],"version-history":[{"count":3,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts\/652\/revisions"}],"predecessor-version":[{"id":655,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts\/652\/revisions\/655"}],"wp:attachment":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/media?parent=652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/categories?post=652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/tags?post=652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}