在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue不用腳手架搭建項目

vue不用腳手架搭建項目

vue直接用vue.js 來創(chuàng)建項目 是不是路由 vuex都不能用了

回答
編輯回答
替身

可以用,vue是一個漸進式的前端框架,漸進式也就意味著你可以在使用過程中,引入自己需要的一系列外部資源。這也就意味著,你可以自己搭建自己的框架,如果不用vue-cli,你可以自己搭建開發(fā)框架,需要vuex、需要vue-router的時候,npm安裝,在項目中import就可以了。
如果你不想使用框架,直接用vue.js構(gòu)建項目,你可以看1樓的回復(fù),用CND的方式引入使用。

2017年1月25日 03:36
編輯回答
墨染殤

可以的,通過CDN方式,在頁面上引入 js 和 css 文件即可開始使用。
案例1:vuex

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
    <script src="https://unpkg.com/vuex@3.0.1/dist/vuex.js"></script>
</head>
<div id="app"></div>
<body>
    <script type="text/Template" id="tpl">
        <div>
            <tip></tip>
            <input type="button" value="+" @click="jia" />
            <input type="button" value="-" @click="jian" />
        </div>
    </script>
    <script>
        const VuexStore = new Vuex.Store({
            state: {
                count: 0,
                num1: 1,
                num2: 2
            },
            mutations: {
                add(state, arg) {
                    state.count += arg.amount;
                },
                reduce(state) {
                    state.count --;
                }
            },
            getters: {
                he(state,getters) {
                    return state.count + state.num1 + state.num2
                },
                add5(state) {
                    return state.count + 0
                }
            },
            actions: {
                add_act({commit}) {
                    commit({type:'add', amount:5})
                },
                reduce_act({commit}) {
                    commit({type:'reduce'})
                }
            },
            modules: {

            }
        });
        const app = new Vue({
            el: '#app',
            store: VuexStore,
            template: '#tpl',
            components: {
                tip: {
                    computed: {
                        ...Vuex.mapState(['count','num1','num2']),
                        // ...Vuex.mapGetters(['he'])代替了$store.getters.he
                        ...Vuex.mapGetters(['he']),
                    },
                    template: '<div>{{count}}-{{num1}}-{{num2}}={{he}}</div>'
                }
            },
            methods: {
                // ...Vuex.mapMutations(['add'])代替了$store.commit('add')
//                ...Vuex.mapMutations(['add','reduce']),
                ...Vuex.mapActions(['add_act', 'reduce_act']),
                jia() {
//                    this.$store.commit({type:'add',amount:100})
//                    this.$store.dispatch('add_act');
                        this.add_act();
//                    this.add({amount:100});
                },
                jian() {
//                    this.$store.commit('reduce');
//                    this.$store.dispatch('reduce_act');
                        this.reduce_act();
//                    this.reduce();
                }
            }
        })
    </script>
</body>
</html>

至于router案例:https://github.com/vuejs/vue-...

2017年1月6日 12:40
編輯回答
糖豆豆

當然可以用啊,你自己引入啊。
腳手架只不過是預(yù)先配置好的一個框架,
你要是喜歡,手動搞一個腳手架一模一樣的代碼結(jié)構(gòu)都行啊。

2017年11月30日 20:24