zoukankan      html  css  js  c++  java
  • vue中的js引入图片,使用require相关问题

    vue中的js引入图片,必须require进来 或者引用网络地址

    <template>
        <div class="home">
            <img alt="Vue logo" src="../assets/logo.png">
            <!--<HelloWorld msg="Welcome to Your Vue.js App"/>-->
    
    
            <template>
                <el-carousel :interval="4000" type="card" height="200px">
                    <el-carousel-item v-for="item in imgList" :key="item.id">
                        <img :src="item.imgSrc" >
                        <!--<img :src="defimg" alt="">-->
    
                    </el-carousel-item>
                </el-carousel>
            </template>
    
        </div>
    </template>
    
    <script>
        // @ is an alias to /src
        // import HelloWorld from '@/components/HelloWorld.vue'
    
        export default {
            name: 'home',
            // components: {
            //     HelloWorld
            // },
            data() {
                return {
    
                    imgList: [
                # 错误❌
                        // {id: 1, imgSrc: jpg1},
                        // {id: 2, imgSrc: jpg1},
                        // {id: 3, imgSrc: jpg1},
                        # 正确✅
                        {id: 1, imgSrc: require("../assets/1.jpg")},
                        {id: 2, imgSrc: require("../assets/2.jpg")},
                        {id: 3, imgSrc: require("../assets/3.jpg")},
                        # 正确✅
                        // {id: 1,imgSrc:"https://hcdn1.luffycity.com/static/frontend/index/banner1(4)_1539945492.0492468.png"},
                        // {id: 2,imgSrc:"https://hcdn1.luffycity.com/static/frontend/index/骑士(1)_1539945488.713867.png"},
                        // {id: 3,imgSrc:"https://hcdn1.luffycity.com/static/frontend/index/banner11_1538122470.2779157.png"},
                    ]
                }
            },
        }
    </script>
  • 相关阅读:
    【sqlite】python备份数据库
    【elasticsearch】python下的使用
    Raft
    SQL注入攻击和防御
    The world beyond batch: Streaming 101
    MillWheel: Fault-Tolerant Stream Processing at Internet Scale
    Flink DataSet API Programming Guide
    The Dataflow Model 论文
    让Storm插上CEP的翅膀
    Siddhi CEP Window机制
  • 原文地址:https://www.cnblogs.com/xzybk/p/11726973.html
Copyright © 2011-2022 走看看