V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
chunhai
V2EX  ›  Vue.js

vue 数据绑定和小程序的问题

  •  
  •   chunhai · 2022-09-20 12:58:31 +08:00 · 958 次点击
    这是一个创建于 555 天前的主题,其中的信息可能已经有所发展或是发生改变。
    		<view class="bg-img bg-mask flex align-center"
    			style="background-image: url('{{img_back.img}}');height: 414upx;">
    			<view class="padding-xl text-white">
    				<view class="padding-xs text-xxl text-bold">
    					{{img_back.title}}
    				</view>
    				<view class="padding-xs text-lg">
    					{{img_back.desc}}
    				</view>
    			</view>
    		</view>
    

    这个 style 俩边的图片链接该怎么写啊?我按照小程序模板语法可以这么写,vue 这样写好像不对。

    sjhhjx0122
        1
    sjhhjx0122  
       2022-09-20 17:01:42 +08:00
    把 style 写成变量 直接:style="style" ? 好久没写小程序忘记语法了
    yaphets666
        2
    yaphets666  
       2022-09-20 17:51:45 +08:00
    :style="'background-image: url'+({{img_back.img}})+';height: 414upx;'"
    yaphets666
        3
    yaphets666  
       2022-09-20 17:53:01 +08:00
    上面多了两个大括号,:style="'background-image: url('+img_back.img+');height: 414upx;'"
    Danswerme
        4
    Danswerme  
       2022-09-20 21:54:28 +08:00
    :style="`background-image: url(${img_back.img});height: 414upx;`"
    chunhai
        5
    chunhai  
    OP
       2022-09-21 00:21:17 +08:00
    @yaphets666 懂了懂了,感谢哈哈
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5115 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 09:44 · PVG 17:44 · LAX 02:44 · JFK 05:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.