默认图
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, onUnmounted, reactive, toRefs } from 'vue'
|
import { ref, onMounted, onUnmounted, reactive, toRefs } from 'vue'
|
||||||
import nullImg from '@/assets/images/shopping-cart-null.png'
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
url: {
|
url: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -42,7 +41,7 @@
|
|||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="commodity-item" :class="{ 'is-download': download }">
|
<div class="commodity-item" :class="{ 'is-download': download }">
|
||||||
<img :src="nullImg" v-loadimg="props.url" alt="" @click="openDetail" />
|
<img v-loadimg="props.url" alt="" @click="openDetail" />
|
||||||
<div class="detail">
|
<div class="detail">
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<div class="name">
|
<div class="name">
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
import img from '@/assets/images/shopping-cart-null.png'
|
||||||
// 加载图片
|
// 加载图片
|
||||||
export default {
|
export default {
|
||||||
name: 'loadimg',
|
name: 'loadimg',
|
||||||
|
beforeMount(el, binding) {
|
||||||
|
if (!el.src) el.src = img
|
||||||
|
},
|
||||||
mounted(el, binding) {
|
mounted(el, binding) {
|
||||||
const src = binding.value
|
const src = binding.value
|
||||||
if (el.src === src) return
|
if (el.src === src) return
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<slot name="checkbox" />
|
<slot name="checkbox" />
|
||||||
<img :src="info.cover" />
|
<img v-loadimg="info.cover" />
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="title">{{ info.title }}</div>
|
<div class="title">{{ info.title }}</div>
|
||||||
<div class="brand" v-if="showBrand" @click="handleBrandClick">
|
<div class="brand" v-if="showBrand" @click="handleBrandClick">
|
||||||
|
|||||||
Reference in New Issue
Block a user