Skip to content

📃 创建微信小程序和支付宝小程序的目录页面,还适合其它非小程序的项目使用

License

Notifications You must be signed in to change notification settings

ChanceYu/app-file-create

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

app-file-create

NPM

Build Status Dependencies Language License

创建微信小程序和支付宝小程序的目录页面,还适合其它非小程序的项目使用,简单易用,功能强大,English

安装

npm install app-file-create --save-dev

参数

名称 类型 默认 描述
root String process.cwd() 创建的文件位置目录
env String wechat 环境类型,alipaywechat,默认wechat
debug Boolean false 是否开启调试模式,默认false,如果为true,则会显示log信息
replace Boolean false 是否替换原来的文件,默认false
dirname String index 文件夹名称,默认index
filename String -- 子文件名称,默认就是上面的dirname(与文件夹名称相同)
files Array [
fileOption
]
子文件配置,fileOption 是个对象参数,或者文件扩展名字符串
fileOption.ext String -- 子文件扩展名
fileOption.filename String -- 子文件名称,默认是optionsfilename,或者optionsdirname(与文件夹名称相同)
fileOption.template String | Function -- 子文件模板内容,如果是函数,那么函数第一个参数就是下面的args参数
fileOption.args Object {} 子文件模板渲染的参数,如果template参数是函数,此参数生效

方法

  • config - 配置默认参数,注意:调用 AppFileCreate([options]) 的参数会覆盖默认的配置
const AppFileCreate = require('app-file-create'); const pageRoot = __dirname + '/pages'; AppFileCreate.config({ root: pageRoot, debug: true });

使用

  • 创建微信小程序页面
// 写法一和写法二作用是一样的 // 写法一: AppFileCreate({ dirname: 'wx_page', files: ['js', 'json', 'wxml', 'wxss'] }); // 写法二: AppFileCreate({ dirname: 'wx_page', files: [{ ext: 'js' }, { ext: 'json' }, { ext: 'wxml' }, { ext: 'wxss' }] });
  • 创建支付宝小程序页面
AppFileCreate({ env: 'alipay', dirname: 'ali_page', files: [ 'js', 'axml', 'acss', { ext: 'json', args: { title: '个人信息' } } ] });
  • 创建其它类型项目文件
AppFileCreate({ env: '', dirname: 'web_page', files: [ 'js', { ext: 'html', template: `<!DOCTYPE html> <html>  <head>  <title></title>  </head>  <body>   </body> </html>` } ] });
  • 创建其它类型项目文件,子文件名称与文件夹不同
AppFileCreate({ env: '', dirname: 'diff_dir_page', filename: 'child', files: ['js', 'css'] });
  • 创建其它类型项目文件,子文件名称自定义
AppFileCreate({ env: '', dirname: 'diff_filename_page', files: [{ ext: 'js', filename: 'a' },{ ext: 'css', filename: 'b' }] });

License

license

About

📃 创建微信小程序和支付宝小程序的目录页面,还适合其它非小程序的项目使用

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published