vue template当中style背景设置不编译问题
时间:2022-06-18 12:38:19|栏目:vue|点击: 次
template中style背景设置不编译
在vue定义的组件当中,直接设置行内style无法显示背景,里面使用config.resolve.alias当中设置的 @等路径符也无法识别
<el-card style="backgroundImage:`url(`图片地址`)" class="box-card" shadow="hover">
解决方法
在将图片资源在vue 的 data当中解析再绑定到页面
<el-card :style="{backgroundImage:`url(${img})`}" class="box-card" shadow="hover">
// data当中定义 组件需要在函数当中返回数据 保证数据的作用域
data: function(){
return {
weatherData:{},
img: require('@assets/image/sunny_n.jpg')
}
},
如何给template组件加背景
<template>
<div class="index_background" >
</div>
</template>
<style>
.index_background{ background: url('~@/../static/images/login-bg.png') center top no-repeat;}
</style>
上一篇:vue视图不更新情况详解
栏 目:vue
下一篇:vue中的严格模式如何取消
本文标题:vue template当中style背景设置不编译问题
本文地址:http://www.codeinn.net/misctech/205140.html






