1、創建components,文件下創建組件,如test.vue
<template>
<view>
<text>我是組件,獲取傳入的參數值{{num}}</text>
</view>
</template>
<script>
export default {
props: [num]
}
</script>
<style lang="scss">
// 組件樣式
</style>
2、創建頁面,調用組件
// 使用
<template>
<test :num="num"></my-component>
</template>
// 引入組件
import testfrom '@/components/test.vue'
export default {
data(){
return {
num: 8
}
},
// 註冊組件
components:{
test
}
}
你是技術宅麼?那就加入我們吧~本博主不一定長期在線,可以進羣大家一起解決問題~
歡迎加入 CSDN技術交流羣2:(點擊即可加羣)QQ羣:456543087
CSDN技術交流羣(已滿員):(點擊即可加羣)QQ羣:681223095。
商務合作@羣主,謝謝!