Vue 引入組件、引入圖片

引入組件的兩種方法

1、全局引入(在App.vue的script標籤中)

1、引入(Import 變量 from 路徑) 
import head form '@/components/head'
import footer form '@/components/footer'

2、註冊(註冊的名字不能是html的關鍵字,因爲要當標籤使用,可能會衝突)
components:{
	'top': head,
	'foot': footer
}

3、使用
<top></top>  <foot></foot>

2、局部引入(在頁面中引入)
1、引入(同上)
2、註冊(同上)
3、使用(同上)

引入圖片的兩種方法

1、引入圖片路徑賦給變量,直接用變量

import pic form './image/pic.png'
data:{
	return{
		img : pic
	}
}

2、使用require( )包着圖片路徑

data() {
	return{
		img: require("../assets/images/pic.png")
	}
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章