Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

照着 demo 弄不出效果 #131

Closed
15697289437 opened this issue Sep 22, 2016 · 4 comments
Closed

照着 demo 弄不出效果 #131

15697289437 opened this issue Sep 22, 2016 · 4 comments

Comments

@15697289437
Copy link

vue template 代码
image

浏览器的 dom
image

@QingWei-Li
Copy link
Contributor

https://codepen.io/QingWei-Li/pen/ozYpNA

你看我复制粘贴的都搞出来了

@15697289437
Copy link
Author

image

@15697289437
Copy link
Author

/webpack.config.js

var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var path = require('path');
module.exports = {
  entry: {
    app: './src/main.js',
    vendors:['vue','vue-router','element-ui']
  },
  output: {
    path: './build',
    publicPath: '/build/',
    filename: 'bundle.js'
  },
  module: {
    loaders: [
      { test: /\.vue$/, loader: 'vue' },
      { test: /\.js$/, exclude: /node_modules/, loader: 'babel'},
      { test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader")   },
      {
        test: /\.(eot|svg|ttf|woff|woff2|png)\w*/,
        loader: 'file'
      },
      { test: /\.less$/, loader: ExtractTextPlugin.extract("css-loader","less-loader") },

    ]
  },
  plugins: [new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'),
    new ExtractTextPlugin("styles.css")],
  devtool: '#source-map'
}

/src/main.js

import Vue from 'vue'
import Element from 'element-ui'
import 'element-ui/lib/theme-default/index.css'
Vue.use(Element)
Vue.config.debug = process.env.NODE_ENV !== 'production'
import app from './app.vue'
const App = new Vue({
  el: 'body',
  components: {
    app
  }
})

/src/app.vue

<template>
  <el-form ref="form" :model="form" label-width="80px" @submit.prevent="onSubmit">
    <el-form-item label="活动名称">
      <el-input v-model="form.name"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary">立即创建</el-button>
      <el-button @click.native.prevent>取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
  export default {
    data() {
      return {
        form: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        }
      }
    },
    methods: {
      onSubmit() {
        console.log('submit!');
      }
    }
  }
</script>

/index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>title</title>
    <meta name="description" content="title">
    <meta name="viewport" content="width=device-width">
    <link rel="stylesheet" href="./build/styles.css">
  </head>
  <body>
    <!--[if lt IE 10]>
      <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
    <![endif]-->
    <app></app>
    <script src="./build/vendors.js"></script>
    <script src="./build/bundle.js"></script>
  </body>
</html>

@QingWei-Li
Copy link
Contributor

QingWei-Li commented Sep 22, 2016

这是给 Vue 2 用的不是给 Vue 1 啊... 如果不清楚 Vue 2 怎么写,请参考官方教程。或者我前面给的 demo

hazel54 pushed a commit to hazel54/element that referenced this issue Aug 29, 2018
add checkbox to tree component
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants