eg: import home from './components/home.vue';
eg: components:,function(err)).catch((error)=>,
『home』:{}}
在父元件中1.呼叫子元件的時候定義乙個ref
在父元件中2.在父元件裡面通過
this.$refs.head.屬性
this.$refs.head.方法
在子元件中通過使用this.$parent.資料、this.$parent.方法來獲取父元件的資料和方法。
通過廣播機制進行傳值,流程如下:
1、新建乙個js檔案 然後引入vue 例項化vue 最後暴露這個例項
eg: import vue from 'vue';
var vueevent = new vue()
export default vueevent;
2、在要廣播的元件引入剛才定義的例項
eg:import vueevent from '../model/vueevent.js';
3、通過 vueemit.$emit('名稱','資料')
eg: vueevent.$emit('to-news',this.msg)
4、在接收資料的元件中通過 $om接收廣播的資料(也需要引入定義的例項物件)
vueemit.$on('名稱',function(),
, /*預設跳轉路由*/
5、例項化vuerouter
eg: const router = new vuerouter(
2、在對應的頁面獲取傳輸的值
this.$route.params獲取動態路由的值
Vue基礎語法2
vue基礎語法1 一 樣式繫結 class繫結 使用方式 v bind class expression expression的型別 字串 陣列 物件 style繫結 v bind style expression expression的型別 字串 陣列 物件 二 事件處理器 之前已學習 事件修飾符...
Vue基礎語法
指令 1.1 資料繫結指令 v pre 填充原始資訊 1.顯示原始資訊跳過編譯過程 v once 只編譯一次 應用場景 顯示的資訊後續不需要修改。1.2 雙向資料繫結type text v model username 1.3 事件繫結type button v on click num type ...
Vue 基礎語法
lang en charset utf 8 模板語法 v指令入門title src script head root div div div v html test2 my.age div div 物件,裡面有兩個最基本屬性,是固定屬性 要寫在 id 為 root 的 div 下面 const co...