Vue+webpack Development (III)

Source: Internet
Author: User

The last blog post tells you how to use routing, this time to talk about how to write a Vue component

Vue defines a file with a "single-file component" suffix of '. Vue ' that looks like this:

<Template>  <Div>    <Divv-for= "N in obj": Class= "MSG"@click= "Say (n)">{{n}}</Div>  </Div></Template><Script>Exportdefault{data: ()={        return{msg:'Hello, I'm slag-shining.', obj: {name:'Zhangxiaomie', Age: A}}, methods:{say (n) {alert (n) }}}</Script><styleLang= "Scss">HTML{background:Red;a{font-weight: -;    }} div{Font-weight:Bold;  }</style>

The visible Vue file is divided into three, which became our usual html+js+css, corresponding to three large tags <template> <script> <style>.

Surprisingly, they can be added with the lang attribute to determine which precompiled language to use, for example: <template lang= "Jade" > <script lang= "typescript" > <style lang= " Scss ">

Of course we need to add vue-loader to the webpack.config.js.

module:{    loaders:[      {        test:/\.vue$/,        loader: ' Vue-loader ',        include:path.resolve (__dirname, ' src ')      }    ]  }

Face Lang,vue-loader will actively look for node_module under there is no corresponding such as Scss-loader, Jade-loader, Typescript-loader and so on loader help us compile, I need us to go webpack.config that configuration again.

Vue+webpack Development (III)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.