Commit c3c822cf by LinChengbiao

配置修改,增加模板页面

parent d7a97085
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
该项目为 `品牌事件库` 的小程序版本,项目使用 `wepy` 框架开发,如果没有使用过,建议去[github.com](https://github.com/Tencent/wepy)看看,并且还需要一定vue基础。 该项目为 `品牌事件库` 的小程序版本,项目使用 `wepy` 框架开发,如果没有使用过,建议去[github.com](https://github.com/Tencent/wepy)看看,并且还需要一定vue基础。
---
## 启动项目 ## 启动项目
* clone 下来项目后先装好相关依赖 * clone 下来项目后先装好相关依赖
...@@ -10,3 +12,44 @@ ...@@ -10,3 +12,44 @@
* 然后运行下面方法,会自动生成 dist文件(编译后小程序可解析的代码) * 然后运行下面方法,会自动生成 dist文件(编译后小程序可解析的代码)
* `npm run dev` * `npm run dev`
* 或者 `wepy build --watch` * 或者 `wepy build --watch`
---
## 注意事项
* **新增页面**
* `src/pages/temp.wpy` 文件为页面模板文件,新建页面直接复制这个然后修改就可以了。(一般情况下,改成如下形式就可以自由添加内容了)
```javascript
<template>
<view class="{文件名}Wpy">
{文件名}
</view>
</template>
<script>
import wepy from 'wepy'
export default class {文件名首字母大写} extends wepy.page {
onLoad () {
console.log('{文件名}')
}
}
</script>
<style lang="less" scoped>
.{文件名}Wpy{}
</style>
```
* 新增的页面必须在 `src/app.wpy` 中配置路径,否则会报错。
* 需要注意 `页面``组件` 的声明方式有所不同:
* 页面声明 `export default class PageName extends wepy.page`
* 组件声明 `export default class ComponentName extends wepy.component`
* 名称(`PageName``ComponentName`)**首字母**要大写
* `PageName``ComponentName` 是自定义的
---
## 参考文档
* [github 项目](https://github.com/Tencent/wepy)
* [微信小程序组件化开发框架WePY官方文档](https://tencent.github.io/wepy/document.html#/)
...@@ -39,8 +39,9 @@ ...@@ -39,8 +39,9 @@
"eslint-plugin-html": "^2.0.1", "eslint-plugin-html": "^2.0.1",
"eslint-plugin-promise": "^3.5.0", "eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^2.0.1", "eslint-plugin-standard": "^2.0.1",
"wepy-eslint": "^1.5.3",
"wepy-compiler-babel": "^1.5.1", "wepy-compiler-babel": "^1.5.1",
"wepy-compiler-less": "^1.3.10" "wepy-compiler-less": "^1.3.10",
"wepy-compiler-sass": "^1.3.12",
"wepy-eslint": "^1.5.3"
} }
} }
{ {
"description": "品牌事件库 for Mini Program", "description": "品牌事件库 for Mini Program",
"setting": { "setting": {
"urlCheck": true, "urlCheck": true,
"es6": false, "es6": false,
"postcss": false, "postcss": false,
"minified": false "minified": false,
}, "newFeature": true
"compileType": "miniprogram", },
"appid": "wx7d6fd5c69f342842", "compileType": "miniprogram",
"projectname": "brand-event-library-mini-program", "appid": "wx7d6fd5c69f342842",
"miniprogramRoot": "./dist" "projectname": "brand-event-library-mini-program",
} "miniprogramRoot": "./dist",
"condition": {}
}
\ No newline at end of file
...@@ -22,13 +22,15 @@ setStore(store) ...@@ -22,13 +22,15 @@ setStore(store)
export default class extends wepy.app { export default class extends wepy.app {
config = { config = {
pages: [ pages: [
'pages/index' 'pages/login',
'pages/home',
'pages/temp'
], ],
window: { window: {
backgroundTextStyle: 'light', backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#fff', navigationBarBackgroundColor: '#000',
navigationBarTitleText: 'WeChat', navigationBarTitleText: '品牌事件库',
navigationBarTextStyle: 'black' navigationBarTextStyle: '#fff'
} }
} }
......
<template>
<view class="homeWpy">
home
</view>
</template>
<script>
import wepy from 'wepy'
export default class Home extends wepy.page {
onLoad () {
console.log('home')
}
}
</script>
<style lang="less" scoped>
.homeWpy{}
</style>
<template>
<view class="loginWpy">
<navigator url="/pages/home">去首页</navigator>
</view>
</template>
<script>
import wepy from 'wepy'
export default class Login extends wepy.page {
onLoad () {
console.log('login')
}
}
</script>
<style lang="less" scoped>
.loginWpy{}
</style>
<template>
<view class="tempWpy">
temp
</view>
</template>
<script>
import wepy from 'wepy'
export default class Temp extends wepy.page {
onLoad () {
console.log('temp')
}
}
</script>
<style lang="less" scoped>
.tempWpy{}
</style>
...@@ -24,9 +24,9 @@ module.exports = { ...@@ -24,9 +24,9 @@ module.exports = {
less: { less: {
compress: prod compress: prod
}, },
/*sass: { sass: {
outputStyle: 'compressed' outputStyle: 'compressed'
},*/ },
babel: { babel: {
sourceMap: true, sourceMap: true,
presets: [ presets: [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment