Skip to content

Commit

Permalink
basic
Browse files Browse the repository at this point in the history
  • Loading branch information
savokiss committed Oct 15, 2016
1 parent bc4a283 commit f46f408
Show file tree
Hide file tree
Showing 16 changed files with 182 additions and 3,304 deletions.
1,662 changes: 45 additions & 1,617 deletions README.md

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions build/webpack.docs.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
var config = require('../config')
var utils = require('./utils')
var webpack = require('webpack')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = merge(baseWebpackConfig, {
module: {
loaders: utils.styleLoaders({ sourceMap: config.docs.productionSourceMap, extract: true })
},
devtool: config.docs.productionSourceMap ? '#source-map' : false,
output: {
path: config.docs.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js'),
publicPath: config.docs.assetsPublicPath
},
vue: {
loaders: utils.cssLoaders({
sourceMap: config.docs.productionSourceMap,
extract: true
})
},
plugins: [
// http://vuejs.github.io/vue-loader/workflow/production.html
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
// extract css into its own file
new ExtractTextPlugin(utils.assetsPath('css/[name].[contenthash].css')),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: process.env.NODE_ENV === 'testing'
? 'index.html'
: config.docs.index,
template: 'docs/index.jade',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
}
})
]
})
9 changes: 8 additions & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './',
assetsPublicPath: '/',
productionSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
Expand All @@ -16,6 +16,13 @@ module.exports = {
productionGzip: false,
productionGzipExtensions: ['js', 'css']
},
docs: {
index: path.resolve(__dirname, 'gh-pages/index.html'),
assetsRoot: path.resolve(__dirname, 'gh-pages'),
assetsSubDirectory: 'static',
assetsPublicPath: '',
productionSourceMap: true
},
dev: {
env: require('./dev.env'),
port: 8088,
Expand Down
12 changes: 6 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<html>
<head><title>pinyin</title>
<link href=./dist/static/css/app.4b3e0d51e2745de27bde2bc46541d2c8.css rel=stylesheet>
<head>
<title>pinyin</title>
</head>

<body>
<div id=app></div>
<script type=text/javascript src=./dist/static/js/manifest.901189d3769700fc5114.js></script>
<script type=text/javascript src=./dist/static/js/vendor.600f59d30fff71db42d5.js></script>
<script type=text/javascript src=./dist/static/js/app.d9c2fe8d4d689048cf30.js></script>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>

</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "pinyin",
"name": "vue-cascading-address",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "savokiss <jaynaruto@qq.com>",
Expand Down
6 changes: 0 additions & 6 deletions params.json

This file was deleted.

83 changes: 0 additions & 83 deletions src/App.vue

This file was deleted.

43 changes: 43 additions & 0 deletions src/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<template>
<div class="container">
<div class="row text-center">
<div class="col-md-12">
<h1> vue城市级联选择 </h1>
</div>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4">
<cascading-address @confirm="confirmCity"></cascading-address>
</div>

</div>
<div class="row">
<div class="col-md-4 col-md-offset-4">
<pre>{{ confirmData || 'confirm事件中的data将显示在此处' }}</pre>
</div>
</div>
</div>
</template>

<script lang="babel">
import cascadingAddress from './cascadingAddress'
export default {
data(){
return {
confirmData : ''
}
},
components: {
cascadingAddress
},
methods: {
confirmCity(data){
this.confirmData = data;
}
}
}
</script>

<style>
</style>
35 changes: 18 additions & 17 deletions src/components/cascadingAddress.vue → src/cascadingAddress.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<template>
<div>
<input v-model="all" @click="open('show')" type="text" class="form-control"
:class="{submmited : !p }" readonly="true"/>
<input v-model="model" @click="open()" type="text" class="form-control" :class="inputClass" readonly/>

<div v-show="show" class="cascading-address">
<ul>
Expand All @@ -26,12 +25,12 @@
<label class="control-label text-success">
<span class="text-muted">地址:</span>
{{ p }} {{ c }} {{ a }} {{ d }}
<!--{{ p }} {{ c }}-->
</label>
</div>

<div class="panel-footer text-right">
<button @click="clear()" class="btn btn-link btn-sm">清空</button>
<button @click="close()" class="btn btn-link btn-sm">关闭</button>
<button @click="clear()" class="btn btn-default btn-sm">清空</button>
<button @click="confirm()" class="btn btn-success btn-sm" :disabled="!(p&&c) && p!='国外'">确定</button>
</div>
</div>
Expand Down Expand Up @@ -63,22 +62,16 @@
.cascading-address .form-group {
margin: 10px;
}
.input.error {
border: solid 1px #a94442;
}
.text-danger {
position: relative;
left: -2px;
}
</style>
<script lang="babel">
import addressData from './cascadingAddressData.json'
export default{
props: {
inputClass: String
},
data(){
return {
all: '',
model: '',
p: '',
c: '',
a: '',
Expand Down Expand Up @@ -119,7 +112,7 @@
// 任何数据变动都更新完整地址
this.$watch(function () {
var address = (this.p + ' ' + this.c + ' ' + this.a + ' ' + this.d);
this.all = address.replace(/undefined *| /g,'');
this.model = address.replace(/undefined *| /g,'');
}).bind(this)
},
clear(){
Expand All @@ -128,11 +121,19 @@
this.a = '';
this.d = '';
},
open(action){
this.show = action === 'show';
open(){
this.show = true;
},
close(){
this.show = false;
},
confirm(){
this.show = false;
this.$emit('confirm', {
province: this.p,
city: this.c,
area: this.a
})
},
setProvince(p){
this.p = p;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Resource from 'vue-resource'
import App from './App'
import App from './app'
import 'bootstrap/dist/css/bootstrap.css'

/* eslint-disable no-new */
new Vue({
el: '#app',
render: h => h(App)
})
});
778 changes: 0 additions & 778 deletions src/pinyin.json

This file was deleted.

Binary file added static/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f46f408

Please sign in to comment.