首页index.vue中写子组件真机调试就不进入,chrome浏览器正常,
在其他页面引用相同子组件没有问题。
index .html代码
<template>
<product-two></product-two>
</template>
<script>
import productTwo from '@/components/product-two';
export default {
components: {
productTwo
},
}
</script>
子组件
<template>
<view class="style-two-main" v-if="productList.length>0">
<view class="uni-product-list">
<view class="width-half" v-for="(product, index) in productList" :key="index">
<view class="uni-product">
<view class="image-view">
<image v-if="renderImage" class="uni-product-image" :src="product.image"></image>
<view class="transfrom-red">推荐</view>
</view>
<view class="uni-product-title">{{ product.title }}</view>
<view class="uni-product-price">
<text class="uni-product-price-favour">¥{{ product.originalPrice }}</text>
<text class="uni-product-price-original">¥{{ product.favourPrice }}</text>
<text class="uni-product-tip">购买</text>
</view>
<view class="uni-product-price" v-if="product.favourPrice == '3399'">
<text class="uni-product-price-favour">¥{{ product.originalPrice }}</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
props: {
options: '',
},
data() {
return {
title: 'product-two',
productList: [],
renderImage: false
};
},
methods: {
loadData(action = 'add') {
const data = [
{
image: '../../static/refresh/release.jpeg',
title: 'Apple iPhone X 256GB 深空灰色 移动联通电信4G手机',
originalPrice: 9999,
favourPrice: 8888,
tip: '自营'
},
{
image: 'https://img-cdn-qiniu.dcloud.net.cn/uploads/example/product2.jpg',
title: 'Apple iPad 平板电脑 2018年新款9.7英寸',
originalPrice: 3499,
favourPrice: 3399,
tip: '优惠'
},
];
if (action === 'refresh') {
this.productList = [];
}
data.forEach(item => {
this.productList.push(item);
});
}
},
created() {
console.log(this.options);
this.loadData();
this.renderImage = true;
},
};
</script>
0 个回复