温度转换设计
Vue.js 起步
每个 Vue 应用都需要通过实例化 Vue 来实现。
语法格式如下:
var vm = new Vue({
// 选项
})
实例
Vue.js 模板语法
Vue.js 使用了基于 HTML 的模板语法,允许开发者声明式地将 DOM 绑定至底层 Vue 实例的数据。
Vue.js 的核心是一个允许你采用简洁的模板语法来声明式的将数据渲染进 DOM 的系统。
结合响应系统,在应用状态改变时, Vue 能够智能地计算出重新渲染组件的最小代价并应用到 DOM 操作上。
文本插值
< div id=“app”>
< p>{{ message }}< /p >
< /div>
指令
指令是带有 v- 前缀的特殊属性,用于在表达式的值改变时,将某些行为应用到 DOM 上。
< div id=“app”>
< p v-if=“seen”>hello< /p>
< /div>
< script>
new Vue({
el: ‘#app’,
data: {
seen: true
}
})
< /script>
Vue.js Ajax(axios)
① GET 方法
new Vue({
el: ‘#app’,
data () {
return {
info: null
}
},
mounted () {
axios
.get(‘https://www.runoob.com/try/ajax/json_demo.json’)
.then(response => (this.info = response))
.catch(function (error) { // 请求失败处理
console.log(error);
});
}
})
②POST 方法
new Vue({
el: ‘#app’,
data () {
return {
info: null
}
},
mounted () {
axios
.post(‘https://www.runoob.com/try/ajax/demo_axios_post.php’)
.then(response => (this.info = response))
.catch(function (error) { // 请求失败处理
console.log(error);
});
}
})