Can we make vue.js application without .vue extension component and webpack?

后端 未结 4 719
执笔经年
执笔经年 2020-12-02 13:43

Note: Can we write vue.js large application without using any compiler for code like currently i see all example use webpack now to make vue.js code compatible for b

4条回答
  •  半阙折子戏
    2020-12-02 14:21

    As stated in this jsFiddle: http://jsfiddle.net/posva/wtpuevc6/ , you have no obligation to use webpack or .vue files.

    The code below is not from me and all credit goes to this jsFiddle creator:

    Create an index.html file:

    
    
    
    
    
    
    
    
    /home /foo

    Home.js

    const Home = { template: '
    Home
    ' }

    Foo.js

    const Foo = { template: '
    Foo
    ' }

    router.js

    const router = new VueRouter({
      mode: 'history',
      routes: [
        { path: '/', component: Home },
        { path: '/foo', component: Foo }
      ]
    })
    

    index.js

    new Vue({
        router,
      el: '#app',
      data: {
        msg: 'Hello World'
      }
    })
    

    Appreciate the framework...

    Just a sidenote: .vue files are really awesome, you should definitely try them if not using them is not a requirement

提交回复
热议问题