Vue.js up and running -- Introduction and basics

Vue.js是一个流行的前端框架,相比jQuery等其他框架,它的代码更易维护和理解。本文将介绍Vue的基本安装、指令、响应式原理、Vue对象及事件和钩子。重点涵盖v-if、v-for、v-model等指令,以及数据响应性、生命周期钩子等核心概念。
摘要由CSDN通过智能技术生成

Vue.js basics

Vue.js is a frontend framework, which is becoming popular these years. comparing with other framework like jQuery( I learned it 4 years ago), vue can write maintable, simpler to reading and understanding code.
In this chapter, I will discuss the install and fundamental elements in vue.

1.Installation and start up

useing the vue-cli tool, install is much easier. check the webside to find documention.
vuejs-templates

$ npm install -g vue-cli
$ vue init webpack my-project
$ cd my-project
$ npm install
$ npm run dev

2.Directives

We use directives to tell Vue what we want to happen and what should do with data, we also can define directives by ourself.
there are some frequent use directives and code samples:

v-if
<p v-if="hours < 12">Good morning!</p>
<p v-if="hours >= 12 && hours < 18">Good afternoon!</p>
v-show
<p v-show="false">one</p>
//equivalent 
<p style="display: none">one</p>
interpolation:{ {path}} visit data in html
<p v-if="path === '/'">You are on home page</p>
// show the value of path
<p v-else="h">You're on {
  {path}}</p>
new Vue({
   
	el: '#app',
	data: {
   
		path: location.pathname
	}
});
v-for

iterator

<li v-for="(rent, city) in averageRent
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值