在根目录下,新建components目录(名称随意) 在components目录下,新建组件i-farame.vue
<template>
<view>
<view class="black">本功能开发中……</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style scoped>
.black{
background-color: #000;
opacity: 0.9;
position: fixed;
width: 100%;
height: 100%;
left: 0;
bottom: 0;
z-index: 10;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
}
</style>
打开要引入组件的vue界面,在script中引入
<script>
import IFrame from "@/components/i-frame.vue";
……
<script>
import IFrame from "@/components/i-frame.vue";
export default {
components: {
IFrame
},
……
<template>
<view>
<i-frame :shishi="12112312" :src="xxxxx"></i-frame>
</view>
</template>
打开i-frame.vue,使用prop接收数据
<script>
export default {
props: ["src", "shishi"],
……
<template>
<view>
{{shishi}}
</view>
</template>
methods: {
abc () {
console.log(this.shishi)
}
}
注意,组件里没有生命周期。