Skip to content

Commit 5049979

Browse files
committed
refactor: Add jsx.
1 parent 3c6ba37 commit 5049979

File tree

8 files changed

+261
-114
lines changed

8 files changed

+261
-114
lines changed

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"targets": {
66
"browsers": ["> 1%", "last 10 versions", "not ie <= 11"]
77
}
8-
}]
8+
}],
9+
'@vue/babel-preset-jsx'
910
],
1011
"plugins": ["@babel/plugin-transform-runtime"],
1112
"env": {

build/webpack.base.conf.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = {
3030
publicPath: isProd ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
3131
},
3232
resolve: {
33-
extensions: ['.js', '.vue', '.json'],
33+
extensions: ['.js', '.jsx', '.vue', '.json'],
3434
alias: {
3535
vue: 'vue/dist/vue.esm.js',
3636
src: resolve('src'),
@@ -42,7 +42,7 @@ module.exports = {
4242
test: /\.(js|vue)$/,
4343
loader: 'eslint-loader',
4444
enforce: 'pre',
45-
include: [resolve('src'), resolve('test'), resolve('test')],
45+
include: [resolve('src'), resolve('example'), resolve('test')],
4646
options: {
4747
formatter: require('eslint-friendly-formatter'),
4848
},
@@ -52,9 +52,9 @@ module.exports = {
5252
loader: 'vue-loader',
5353
},
5454
{
55-
test: /\.js$/,
55+
test: /\.js[x]$/,
5656
loader: 'babel-loader',
57-
include: [resolve('src'), resolve('test'), resolve('test')],
57+
include: [resolve('src'), resolve('example'), resolve('test')],
5858
},
5959
{
6060
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,

example/App.jsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import Basic from './Basic';
2+
import VirtualList from './VirtualList';
3+
import SelectControl from './SelectControl';
4+
import './styles.less';
5+
6+
export default {
7+
render() {
8+
const list = [
9+
{
10+
title: 'Basic Use',
11+
key: 'basic',
12+
component: <Basic />,
13+
},
14+
{
15+
title: 'Virtual List',
16+
key: 'virtual-list',
17+
component: <VirtualList />,
18+
},
19+
{
20+
title: 'Selector',
21+
key: 'select-control',
22+
component: <SelectControl />,
23+
},
24+
];
25+
26+
return (
27+
<div class="example">
28+
{list.map(item => (
29+
<div class="example-box" id={item.key}>
30+
<h2 class="title">{item.title}</h2>
31+
{item.component}
32+
</div>
33+
))}
34+
35+
<a
36+
style="position: fixed; right: 0; top: 0;"
37+
href="https://github.com/leezng/vue-json-pretty"
38+
target="_blank"
39+
>
40+
<img
41+
style="position: absolute; top: 0; right: 0; border: 0;"
42+
src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67"
43+
alt="Fork me on GitHub"
44+
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"
45+
/>
46+
</a>
47+
</div>
48+
);
49+
},
50+
};

example/App.vue

Lines changed: 0 additions & 108 deletions
This file was deleted.

example/SelectControl.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<div>
1010
<label>selectableType</label>
1111
<select v-model="selectableType">
12-
<option label="-" />
1312
<option>single</option>
1413
<option>multiple</option>
1514
</select>

example/styles.less

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
html,
2+
body {
3+
margin: 0;
4+
background-color: #f9f9f9;
5+
}
6+
.example {
7+
position: relative;
8+
padding: 0 15px;
9+
margin: 0 auto;
10+
width: 1200px;
11+
}
12+
.example-box {
13+
margin: 0 -15px;
14+
overflow: hidden;
15+
h3 {
16+
display: inline-block;
17+
}
18+
.title {
19+
text-align: center;
20+
}
21+
.block {
22+
float: left;
23+
padding: 0 15px;
24+
width: 50%;
25+
box-sizing: border-box;
26+
}
27+
input,
28+
select,
29+
textarea {
30+
padding: 3px 8px;
31+
box-sizing: border-box;
32+
border-radius: 5px;
33+
border: 1px solid #bbb;
34+
font-family: inherit;
35+
&:focus {
36+
outline: none;
37+
border-color: #1d8ce0;
38+
box-shadow: 0 0 3px #1d8ce0;
39+
}
40+
}
41+
textarea {
42+
width: 100%;
43+
height: 150px;
44+
resize: vertical;
45+
}
46+
pre {
47+
margin: 0;
48+
font-family: Consolas;
49+
overflow: hidden;
50+
text-overflow: ellipsis;
51+
}
52+
.options {
53+
font-size: 14px;
54+
}
55+
}

0 commit comments

Comments
 (0)