天下无坑

天下无坑


vue组件开发规范

<p><code>遵照ydui的组件结构</code> <a href="https://github.com/ydcss/vue-ydui/tree/master/src/components" title="ydui">ydui</a></p> <h3>组件文件结构</h3> <pre><code>/src/components/COMPNAME/ /src/components/COMPNAME/index.js /src/components/COMPNAME/src/COMPNAME.vue /src/components/COMPNAME/src/OTHENAME.vue /src/components/styles/COMPNAME.less[css]</code></pre> <pre><code class="language-html"> &lt;style lang="less"&gt; @import '../styles/COMPNAME.less'; &lt;/style&gt; &lt;template&gt; &lt;div :right="right"&gt; {{ msg }} &lt;/div&gt; &lt;/template&gt; &lt;script type="text/babel"&gt; // import {OTHENAME} from './OTHENAME'; export default { name: 'COMPNAME', components: {}, // 组件内部属性 data() { return { msg: 'hello' } }, // 接收来自父组件的属性 props: { right: { type: String, default: '5%' }, }, // 计算属性 会缓存 多个值影响一个值 // 默认只读,可通过声明setter,getter实现可读可写 computed:{ }, // 侦听器 不缓存,一个值影响多个值,可以侦听 data、props、computed、$emit watch:{ }, methods: { someMethod() { }, }, //...其他钩子函数 } &lt;/script&gt; </code></pre>

页面列表

ITEM_HTML