国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

詳解auto-vue-file:一個自動創(chuàng)建vue組件的包

2019-11-19 11:41:47
字體:
供稿:網(wǎng)友

auto-vue-file

auto create .vue file by shell command

通過終端自動創(chuàng)建vue文件

前言:

1: 我們在寫xxx.vue頁面文件的時候,一般都要寫這些重復(fù)的代碼:

<template> <div class="zlj-comp-ct"> zlj組件 </div></template><script>export default { name: 'zlj'}</script><style lang="scss" scoped>.zlj-comp-ct {}</style>

2:寫組件的時候可能還要在components目錄下面新建一個目錄:xxx,里面是xxx.vue和index.js

比如myForm組件

// myForm.vue<template> <div class="myForm-comp-ct"> myForm組件 </div></template><script>export default { name: 'myForm'}</script><style lang="scss" scoped>.myForm-comp-ct {}</style>// index.jsimport myForm from './myForm.vue'export default myForm

每次都寫這些代碼,是不是很煩?

主角登場:auto-vue-file

安裝

npm install auto-vue-file -g

使用

 auto-vue-file -c

結(jié)果

這樣在components目錄下面生成myForm文件

參數(shù)說明:

名稱 說明 使用例子
component 創(chuàng)建一個vue組件, 默認在components目錄下面 auto-vue-file -c 或 auto-vue-file --component
page 創(chuàng)建一個vue組件,默認在views目錄 auto-vue-file -p 或 auto-vue-file --page
path 在指定目錄創(chuàng)建vue組件,需要提供-c或-p參數(shù) auto-vue-file -c --path ./src/haha 或 auto-vue-file -p --path ./src/haha

更多:

你也可以使用自己的vue模版文件,文件名為auto-vue-file.template.js,存放在項目根目錄下面,內(nèi)容如下

// template.js you can generate// auto-vue-file.template.js  module.exports = {   vueTemplate: componentName => {   return `<template>   <div class="${componentName}-comp-ct">   ${componentName}組件   </div>  </template>  <script>  export default {   name: '${componentName}'  }  </script>  <style lang="scss" scoped>  .${componentName}-comp-ct {    }  </style>  `   },   entryTemplate: componentName => {   return `import ${componentName} from './${componentName}.vue'  export default ${componentName}`}  }

你也可以執(zhí)行

auto-vue-file --init

自動生成該配置文件:auto-vue-file.template.js

然后改成你自己需要的樣子。

總結(jié)

以上所述是小編給大家介紹的uto-vue-file:一個自動創(chuàng)建vue組件的包,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復(fù)大家的!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 武邑县| 刚察县| 兰坪| 新密市| 瑞金市| 萨迦县| 山阳县| 上栗县| 嘉义县| 武城县| 合阳县| 深州市| 辉南县| 揭西县| 南投县| 偃师市| 平谷区| 西贡区| 正宁县| 河源市| 广德县| 西丰县| 南宫市| 犍为县| 黄骅市| 茂名市| 嘉善县| 东方市| 自治县| 肃北| 神池县| 郎溪县| 桐乡市| 车险| 报价| 德江县| 化德县| 阳东县| 石屏县| 秀山| 富裕县|