/src/$1"
11 | },
12 | snapshotSerializers: ["jest-serializer-vue"],
13 | testMatch: [
14 | "**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"
15 | ],
16 | testURL: "http://localhost/"
17 | };
18 |
--------------------------------------------------------------------------------
/演示DEMO源码/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "geektime-vue",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "serve": "vue-cli-service serve",
7 | "build": "vue-cli-service build",
8 | "lint": "vue-cli-service lint",
9 | "test:e2e": "vue-cli-service test:e2e",
10 | "test:unit": "vue-cli-service test:unit"
11 | },
12 | "dependencies": {
13 | "@vue/babel-helper-vue-jsx-merge-props": "^1.0.0-beta.2",
14 | "@vue/babel-preset-jsx": "^1.0.0-beta.2",
15 | "ant-design-vue": "^1.3.5",
16 | "moment": "^2.24.0",
17 | "vue": "^2.6.8",
18 | "vue-ref": "^1.0.4",
19 | "vue-router": "^3.0.1",
20 | "vuex": "^3.0.1"
21 | },
22 | "devDependencies": {
23 | "@vue/cli-plugin-babel": "^3.4.0",
24 | "@vue/cli-plugin-e2e-cypress": "^3.4.0",
25 | "@vue/cli-plugin-eslint": "^3.4.0",
26 | "@vue/cli-plugin-unit-jest": "^3.4.0",
27 | "@vue/cli-service": "^3.4.0",
28 | "@vue/eslint-config-prettier": "^4.0.1",
29 | "@vue/test-utils": "^1.0.0-beta.20",
30 | "babel-core": "7.0.0-bridge.0",
31 | "babel-eslint": "^10.0.1",
32 | "babel-jest": "^23.6.0",
33 | "eslint": "^5.8.0",
34 | "eslint-plugin-vue": "^5.0.0",
35 | "less": "^3.0.4",
36 | "less-loader": "^4.1.0",
37 | "vue-template-compiler": "^2.6.8"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/演示DEMO源码/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | autoprefixer: {}
4 | }
5 | };
6 |
--------------------------------------------------------------------------------
/演示DEMO源码/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geektime-geekbang/geektime-vue-1/1dc856cf235869163437ce8e9d21833dfa1b53b1/演示DEMO源码/public/favicon.ico
--------------------------------------------------------------------------------
/演示DEMO源码/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | geektime-vue
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
16 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/geektime-geekbang/geektime-vue-1/1dc856cf235869163437ce8e9d21833dfa1b53b1/演示DEMO源码/src/assets/logo.png
--------------------------------------------------------------------------------
/演示DEMO源码/src/components/HelloWorld.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
{{ msg }}
4 |
5 | For a guide and recipes on how to configure / customize this project,
6 | check out the
7 | vue-cli documentation.
10 |
11 |
Installed CLI Plugins
12 |
46 |
Essential Links
47 |
70 |
Ecosystem
71 |
102 |
103 |
104 |
105 |
113 |
114 |
115 |
131 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import antd from "ant-design-vue";
3 | import ref from "vue-ref";
4 | import App from "./App.vue";
5 | import router from "./router";
6 | import store from "./store";
7 | import "ant-design-vue/dist/antd.css";
8 |
9 | Vue.config.productionTip = false;
10 |
11 | Vue.use(antd);
12 | Vue.use(ref, { name: "ant-ref" });
13 |
14 | new Vue({
15 | router,
16 | store,
17 | render: h => h(App)
18 | }).$mount("#app");
19 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/router.js:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import Router from "vue-router";
3 | import Home from "./views/Home.vue";
4 |
5 | Vue.use(Router);
6 |
7 | export default new Router({
8 | routes: [
9 | {
10 | path: "/",
11 | name: "home",
12 | component: Home
13 | },
14 | {
15 | path: "/1.4",
16 | name: "如何触发组件的更新",
17 | component: () => import("./views/1.4")
18 | },
19 | {
20 | path: "/1.5",
21 | name: "合理应用计算属性和侦听器",
22 | component: () => import("./views/1.5")
23 | },
24 | {
25 | path: "/1.6",
26 | name: "生命周期的应用场景和函数式组件",
27 | component: () => import("./views/1.6")
28 | },
29 | {
30 | path: "/1.7",
31 | name: "指令的本质",
32 | component: () => import("./views/1.7")
33 | },
34 | {
35 | path: "/1.8",
36 | name: "provie/inject",
37 | component: () => import("./views/1.8")
38 | },
39 | {
40 | path: "/1.9",
41 | name: "如何优雅的获取跨层级组件(拒绝递归)",
42 | component: () => import("./views/1.9")
43 | },
44 | {
45 | path: "/1.10",
46 | name: "template 和 JSX 对比及其他们的本质",
47 | component: () => import("./views/1.10")
48 | }
49 | ]
50 | });
51 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/store.js:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import Vuex from "vuex";
3 |
4 | Vue.use(Vuex);
5 |
6 | export default new Vuex.Store({
7 | state: {},
8 | mutations: {},
9 | actions: {}
10 | });
11 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.10/AnchoredHeading.js:
--------------------------------------------------------------------------------
1 | export default {
2 | props: {
3 | level: {
4 | type: Number,
5 | default: 1
6 | }
7 | },
8 | render: function(createElement) {
9 | return createElement(
10 | "h" + this.level, // 标签名称
11 | this.$slots.default // 子元素数组
12 | );
13 | }
14 | };
15 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.10/AnchoredHeading.jsx:
--------------------------------------------------------------------------------
1 | export default {
2 | props: {
3 | level: {
4 | type: Number,
5 | default: 1
6 | }
7 | },
8 | render: function(h) {
9 | const Tag = `h${this.level}`;
10 | return {this.$slots.default};
11 | }
12 | };
13 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.10/AnchoredHeading.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
31 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.10/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Message: {{ msg }}
4 |
5 |
6 |
Hello world!
7 |
Hello world!
8 |
Hello world!
9 |
10 |
11 |
12 |
43 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.4/PropsAndData.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
props.info: {{ info }}
4 |
props.name: {{ name }}
5 |
props.list: {{ list }}
6 |
data.a: {{ a }}
7 |
8 |
9 |
10 |
11 |
12 |
37 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.4/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
45 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.5/Computed.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Reversed message1: "{{ reversedMessage1 }}"
4 |
Reversed message2: "{{ reversedMessage2() }}"
5 |
{{ now }}
6 |
7 |
8 |
9 |
10 |
11 |
42 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.5/Computed1.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
29 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.5/Watch.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ $data }}
4 |
5 |
6 |
7 |
8 |
48 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.5/Watch1.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
28 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.5/Watch1_pro.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
34 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.5/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
37 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.6/Clock.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ log("render") }}
4 | {{ now }}
5 |
6 |
7 |
8 |
63 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.6/Functional.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ props }}
4 |
5 |
6 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.6/TempVar.js:
--------------------------------------------------------------------------------
1 | export default {
2 | functional: true,
3 | render: (h, ctx) => {
4 | return ctx.scopedSlots.default && ctx.scopedSlots.default(ctx.props || {});
5 | }
6 | };
7 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.6/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
16 |
17 | {{ var1 }}
18 | {{ var2 }}
19 |
20 |
21 |
22 |
23 |
24 |
25 |
43 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.7/CustomerDirectives.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
9 |
10 |
11 |
43 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.7/Directives.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
v-text
4 |
hello world
5 |
v-html
6 |
7 | hello world
8 |
9 |
v-show
10 |
hello vue
11 |
12 |
v-if v-esle-if v-else
13 |
hello vue {{ number }}
14 |
hello world {{ number }}
15 |
hello geektime {{ number }}
16 |
v-for v-bind
17 |
hello vue {{ num }}
18 |
v-on
19 |
20 |
v-model
21 |
22 |
v-pre
23 |
{{ this will not be compiled }}
24 |
v-once
25 |
26 | {{ number }}
27 |
28 |
29 |
30 |
42 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.7/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
21 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.8/ChildrenA.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
A 结点
4 |
5 |
6 |
7 |
8 |
9 |
10 |
48 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.8/ChildrenA_a.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
A 结点
4 |
5 |
6 |
7 |
8 |
9 |
10 |
40 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.8/ChildrenB.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
B 结点
4 |
5 |
6 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.8/ChildrenC.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
C 结点
4 |
5 |
6 |
7 |
8 |
25 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.8/ChildrenD.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
D 结点
4 |
5 |
6 |
7 |
8 |
9 |
21 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.8/ChildrenE.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
E 结点
4 |
5 |
6 |
7 |
24 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.8/ChildrenF.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
F 结点
4 |
5 |
6 |
17 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.8/ChildrenG.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
G 结点
4 |
5 |
6 |
9 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.8/ChildrenH.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
H 结点
4 |
5 |
6 |
9 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.8/ChildrenI.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
I 结点
4 |
5 |
6 |
15 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.8/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
17 |
32 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.9/ChildrenA.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
A 结点
4 |
5 |
6 |
7 |
8 |
9 |
10 |
45 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.9/ChildrenB.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
B 结点
4 |
5 |
6 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.9/ChildrenC.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
C 结点
4 |
5 |
6 |
7 |
8 |
18 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.9/ChildrenD.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
D 结点
4 |
5 |
6 |
7 |
8 |
9 |
26 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.9/ChildrenE.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | E 结点
5 |
6 |
7 |
8 |
18 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.9/ChildrenF.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
F 结点
4 |
5 |
6 |
7 |
8 |
31 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.9/ChildrenG.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
G 结点
4 |
5 |
6 |
9 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.9/ChildrenH.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
H 结点
4 |
5 |
6 |
9 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.9/ChildrenI.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
I 结点
4 |
5 |
6 |
15 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/1.9/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
14 |
29 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/About.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
This is an about page
4 |
5 |
6 |
--------------------------------------------------------------------------------
/演示DEMO源码/src/views/Home.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{ name }}章节
6 |
7 |
8 |
9 |
10 |
11 |
50 |
51 |
63 |
--------------------------------------------------------------------------------
/演示DEMO源码/tests/e2e/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: ["cypress"],
3 | env: {
4 | mocha: true,
5 | "cypress/globals": true
6 | },
7 | rules: {
8 | strict: "off"
9 | }
10 | };
11 |
--------------------------------------------------------------------------------
/演示DEMO源码/tests/e2e/plugins/index.js:
--------------------------------------------------------------------------------
1 | // https://docs.cypress.io/guides/guides/plugins-guide.html
2 |
3 | // if you need a custom webpack configuration you can uncomment the following import
4 | // and then use the `file:preprocessor` event
5 | // as explained in the cypress docs
6 | // https://docs.cypress.io/api/plugins/preprocessors-api.html#Examples
7 |
8 | /* eslint-disable import/no-extraneous-dependencies, global-require, arrow-body-style */
9 | // const webpack = require('@cypress/webpack-preprocessor')
10 |
11 | module.exports = (on, config) => {
12 | // on('file:preprocessor', webpack({
13 | // webpackOptions: require('@vue/cli-service/webpack.config'),
14 | // watchOptions: {}
15 | // }))
16 |
17 | return Object.assign({}, config, {
18 | fixturesFolder: "tests/e2e/fixtures",
19 | integrationFolder: "tests/e2e/specs",
20 | screenshotsFolder: "tests/e2e/screenshots",
21 | videosFolder: "tests/e2e/videos",
22 | supportFile: "tests/e2e/support/index.js"
23 | });
24 | };
25 |
--------------------------------------------------------------------------------
/演示DEMO源码/tests/e2e/specs/test.js:
--------------------------------------------------------------------------------
1 | // https://docs.cypress.io/api/introduction/api.html
2 |
3 | describe("My First Test", () => {
4 | it("Visits the app root url", () => {
5 | cy.visit("/");
6 | cy.contains("h1", "Welcome to Your Vue.js App");
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/演示DEMO源码/tests/e2e/support/commands.js:
--------------------------------------------------------------------------------
1 | // ***********************************************
2 | // This example commands.js shows you how to
3 | // create various custom commands and overwrite
4 | // existing commands.
5 | //
6 | // For more comprehensive examples of custom
7 | // commands please read more here:
8 | // https://on.cypress.io/custom-commands
9 | // ***********************************************
10 | //
11 | //
12 | // -- This is a parent command --
13 | // Cypress.Commands.add("login", (email, password) => { ... })
14 | //
15 | //
16 | // -- This is a child command --
17 | // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18 | //
19 | //
20 | // -- This is a dual command --
21 | // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22 | //
23 | //
24 | // -- This is will overwrite an existing command --
25 | // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
26 |
--------------------------------------------------------------------------------
/演示DEMO源码/tests/e2e/support/index.js:
--------------------------------------------------------------------------------
1 | // ***********************************************************
2 | // This example support/index.js is processed and
3 | // loaded automatically before your test files.
4 | //
5 | // This is a great place to put global configuration and
6 | // behavior that modifies Cypress.
7 | //
8 | // You can change the location of this file or turn off
9 | // automatically serving support files with the
10 | // 'supportFile' configuration option.
11 | //
12 | // You can read more here:
13 | // https://on.cypress.io/configuration
14 | // ***********************************************************
15 |
16 | // Import commands.js using ES2015 syntax:
17 | import "./commands";
18 |
19 | // Alternatively you can use CommonJS syntax:
20 | // require('./commands')
21 |
--------------------------------------------------------------------------------
/演示DEMO源码/tests/unit/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | jest: true
4 | }
5 | };
6 |
--------------------------------------------------------------------------------
/演示DEMO源码/tests/unit/example.spec.js:
--------------------------------------------------------------------------------
1 | import { shallowMount } from "@vue/test-utils";
2 | import HelloWorld from "@/components/HelloWorld.vue";
3 |
4 | describe("HelloWorld.vue", () => {
5 | it("renders props.msg when passed", () => {
6 | const msg = "new message";
7 | const wrapper = shallowMount(HelloWorld, {
8 | propsData: { msg }
9 | });
10 | expect(wrapper.text()).toMatch(msg);
11 | });
12 | });
13 |
--------------------------------------------------------------------------------