Vue 學習0——API的使用

  • render內置方法

前言:在頁面上渲染數據,我們可以通過new Vue然後在components聲明組件名稱,也可以通過render內置方法,效果等同。

demo

App.vue

<template>
	<div id="app">
		{{hello}}
	</div>
</template>

<script>
	export default {
		data() {
			return {
				hello: 'world'
			}
		}
	}
</script>

<style>
	html {
		height: 100%;
	}

	body {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	#app {
		color: #2c3e50;
		margin-top: -100px;
		max-width: 600px;
		font-family: Source Sans Pro, Helvetica, sans-serif;
		text-align: center;
	}
</style>

main.js

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
	el: '#app',
	/* es6語法 */
	render: (h) => h(App)
})

v-html

<template>
	<!-- 或者簡寫成      :title="hello" -->
	<div id="app">
		<p v-html="hello"></p>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				hello: 'world'
			}
		}
	}
</script>

<style>
</style>

v-text和v-html的區別?

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章