学习黑马程序员的微信小程序开发教程
项目文件夹
1. pages:存所有小程序页面,以单独文件夹存在,如index、list、list2、logs
这些文件夹中都含有4个基本文件
a) .js文件:页面脚本文件,存页面数据、事件处理函数等
b) .json文件:页面配置文件,配置窗口外观、表现等,页面中的配置项会覆盖app.json的window中相同的配置项
如:增加index.json配置
{
"usingComponents": {},
"navigationBarBackgroundColor":"#00b26a"
}
c) .wxml文件:页面模板结构文件
d) .wxss文件:当前页面样式表文件
2. utils:存工具性模块,主要为格式化时间模块
3. app.js:入口文件
4. app.json:全局配置文件
{
"pages":[
"pages/list2/list2",
"pages/list/list",
"pages/index/index",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle":"black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
a) pages:记录属于页面路径
b) window:全局定义所有页面的背景色、文字颜色等
c) style:全局组件所使用的样式版本
d) sitemapLocation:指明sitemap.json的位置
5. app.wxss: 全局样式文件
6. project.config.json:项目配置文件,对小程序开发工具所做的个性化配置
a) setting:存编译相关的配置
b) projectname:存项目名称
c) appid:存小程序的账号id
{
"description": "项目配置文件",
"packOptions": {
"ignore": [
{
"type": "file",
"value": ".eslintrc.js"
}
]
},
"setting": {
"urlCheck": true,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": true,
"lazyloadPlaceholderEnable": false,
"useMultiFrameRuntime": false,
"useApiHook": false,
"useApiHostProcess": false,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"useIsolateContext": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"disableUseStrict": false,
"minifyWXML": true,
"showES6CompileOption": false,
"useCompilerPlugins": false,
"ignoreUploadUnusedFiles": true
},
"compileType": "miniprogram",
"libVersion": "2.19.4",
"appid": "wx06b4431fc1c6e4bf",
"projectname": "one",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"staticServerOptions": {
"baseURL": "",
"servePath": ""
},
"isGameTourist": false,
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"game": {
"list": []
},
"plugin": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": []
}
}
}
7. sitemap.json:配置小程序及其页面是否被微信索引
{
"desc":"关于本文件的更多信息,请参考文档https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}
a) action也可为disallow
b) sitemap的索引提示是默认开启的,如需关闭,可在project.config的setting中配置字段checkSiteMap为false
注:JSON是一种数据格式,总是以配置文件形式出现