Vue深入-26【环境配置、基础代码编写】

一.环境配置

npm init -y
npm install webpack webpack-cli webpack-dev-server
npm install html-webpack-plugin

(1).webpack.config.js

let path = require('path');
let HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
    entry:'./src/index.js',
    output:{
        filename:'bundle.js',
        path:path.resolve(__dirname,'dist')
    },
    devtool:'source-map',
    resolve:{
        modules:[path.resolve(__dirname,'source'),path.resolve('node_modules')]
    },
    plugins:[
        new HtmlWebpackPlugin({
            template:path.resolve(__dirname,'public/index.html')
        })
    ]
}

(2).package.json

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev":"webpack-dev-server",
    "build":"webpack"
  },

二.基础代码编写

source/vue下建立index.js

src/index.js

import Vue from 'vue';
let vm = new Vue({
    el:'#app',
    data(){
        return{
            message:'Hello ZZa',
            nums:[1,5,7],
            person:{
                name:'Mike',
                age:20
            }
        }
    },
    computed:{},
    watch:{}
})

source/vue index.js

import { initState } from './observe';
function Vue(options){
    this._init(options);
}
Vue.prototype._init = function(options){
    let vm = this;
    vm.$options = options;
    initState(vm);
}
export default Vue;

observe/index.js

export function initState(){
    console.log('init State');
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值