最近在学习 Vue ,利用 vue-cli 搭建了一个最简单的模板,然后一步步看着 Vuex, Vux-router 官方文档逐步加上了 Vuex, Vue-Router, Mock-server, Unit-test 。之后还会继续完善下去。。。
GitHub: https://github.com/yanm1ng/vue-starter-kit
A Vue.js project with mock-server and unit-test
we use mock.js to build your mock data ( as local database :) ), for example:
var Mock = require('mockjs');
module.exports = () => {
var db = {
project_comments: Mock.mock({
"comments|5": [{
"author": "@name",
"comment": "@cparagraph",
"date": "@datetime"
}],
"next": "@increment"
}),
push_comment: Mock.mock({
"error": 0,
"message": "成功"
})
}
return db;
}
we use json-server
to get a full fake REST API
test components and vuex( include mutations
actions
getters
), test result:
# install json-server
npm install json-server -g
# install dependencies
npm install
# serve with hot reload and mock
npm run start
# serve with hot reload at localhost:8181
npm run dev
# run unit test
npm run test
# run mock server at localhost:3000
npm run mock
# build for production with minification
npm run build
vuex
to manage app statemock/db.js
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.