Skip to content

Commit b9418e4

Browse files
committed
修改bug.
1 parent 87e3dbb commit b9418e4

File tree

10 files changed

+105
-55
lines changed

10 files changed

+105
-55
lines changed

build/vendor_manifest.json

+1-1
Large diffs are not rendered by default.

build/webpack.base.conf.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ module.exports = {
1818
},
1919
resolve: {
2020
extensions: ['.ts', '.js', '.json'],
21-
alias: {}
21+
alias: {
22+
'vue': 'vue/dist/vue.min.js',
23+
}
2224
},
2325
module: {
2426
rules: [{
@@ -74,4 +76,3 @@ module.exports = {
7476
}),
7577
]
7678
}
77-

build/webpack.dll.conf.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
1-
var path = require('path');
1+
const path = require('path');
22
const webpack = require('webpack');
33
const vendors = [
44
'es6-promise',
55
'axios',
66
'js-cookie',
77
'lodash',
88
'moment',
9-
'vue',
9+
'vue/dist/vue.min.js',
1010
'vuex',
1111
'vue-i18n',
1212
'vue-router',
1313
'vue-class-component',
14-
// "element-ui": "^1.4.0",
14+
'vue-property-decorator',
15+
'vuex-class',
16+
'element-ui',
1517
];
1618

1719
module.exports = {
1820
entry: {
1921
vendor: vendors
2022
},
2123
resolve: {
22-
extensions: [".js", ".jsx"]
24+
extensions: [".js", ".jsx"],
25+
alias: {
26+
'vue': 'vue/dist/vue.min.js',
27+
}
2328
},
2429
output: {
2530
path: path.resolve(__dirname, '../static'),
2631
filename: '[name].dll.js',
2732
library: '[name]_library'
2833
},
2934
plugins: [
35+
new webpack.DefinePlugin({
36+
'process.env.NODE_ENV': JSON.stringify('production')
37+
}),
3038
new webpack.DllPlugin({
3139
context: __dirname,
3240
path: path.resolve(__dirname, '../build/[name]_manifest.json'),
@@ -38,4 +46,4 @@ module.exports = {
3846
},
3947
}),
4048
]
41-
};
49+
};

config/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828
},
2929
dev: {
3030
env: require('./dev.env'),
31-
port: 3000,
31+
port: 3001,
3232
autoOpenBrowser: false,
3333
assetsSubDirectory: 'static',
3434
assetsPublicPath: '/',

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "admin-ts",
2+
"name": "vue-typescript-ts",
33
"version": "1.0.0",
44
"description": "A Vue.js project",
55
"author": "wangchenhao <[email protected]>",

src/Basic.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import 'es6-promise/auto';
21
import _ from 'lodash';
32
import Cookie from 'js-cookie';
43
import Vue from 'vue';
5-
import ElementUI from 'element-ui';
64
import './assets/style/index.scss';
5+
import ElementUI from 'element-ui';
76
import config from './config';
87
import Common from './common';
98
import i18n from './i18n';
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// The Vue build version to load with the `import` command
22
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3-
import { Vue, i18n } from '../../Basic';
4-
import router from '../../router';
5-
import store from '../../store';
3+
import { Vue, i18n } from '../Basic';
4+
import router from '../router';
5+
import store from '../store';
6+
// import App from '../views/main/index';
67
// tslint:disable-next-line:no-unused-expression
78
new Vue({
89
el: '#app',
910
router,
1011
store,
1112
i18n,
13+
// template: '<app></app>',
14+
// components: { App },
1215
});

src/views/Basis.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1-
// import Vue from 'vue';
2-
// import Component from 'vue-class-component';
3-
import { Vue, Component, Watch, Inject, Provide, Model, Prop, Emit } from 'vue-property-decorator';
1+
import Vue from 'vue';
2+
import Component from 'vue-class-component';
3+
import { Watch, Inject, Provide, Model, Prop, Emit } from 'vue-property-decorator';
44
/**
55
* 基类用来定义共用方法
66
* @export
77
* @class Basis
88
* @extends {Vue}
99
*/
1010
export class Basis extends Vue {
11+
/**
12+
* 将字符串转换为数组
13+
* @param {string} str 字符串
14+
* @returns {string[]} 返回数组
15+
* @memberof Basis
16+
*/
17+
strToArray(str: string, ...arge: any[]): any[] {
18+
const format = arge[0] || ',';
19+
if (this.$_.isString(str)) {
20+
return str.split(',');
21+
}
22+
if (str) {
23+
console.warn('[Basis Warn]:需要转换的不是字符串!');
24+
}
25+
return [];
26+
}
1127
}
1228
export { Component, Watch, Inject, Provide, Model, Prop, Emit };

src/views/main/index.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
import { Basis, Component } from '../Basis';
2-
32
@Component({
43
template: require('./layout.html'),
54
})
65
class Main extends Basis {
7-
constructor() {
8-
super();
9-
}
106
mounted() {
117
const loadEl = document.getElementById('loading');
128
if (loadEl) {
139
loadEl.style.display = 'none';
1410
}
15-
this.$http({
16-
url: '/public/reset',
17-
method: 'post',
18-
params: {
19-
ID: 12345,
20-
},
21-
// get 不会发送 data 中的数据
22-
data: {
23-
firstName: 'Fred',
24-
},
25-
}).then((response) => {
26-
console.log(response);
27-
}).catch((error) => {
11+
try {
12+
this.$http({
13+
url: '/public/reset',
14+
method: 'post',
15+
params: {
16+
ID: 12345,
17+
},
18+
// get 不会发送 data 中的数据
19+
data: {
20+
firstName: 'Fred',
21+
},
22+
}).then((response) => {
23+
console.log(response);
24+
}).catch((error) => {
25+
console.log(error);
26+
});
27+
} catch (error) {
2828
console.log(error);
29-
});
29+
}
3030
}
3131

3232
open() {

static/vendor.dll.js

+42-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)