chunhai
V2EX  ›  Vue.js

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

  •  
  •   chunhai · Sep 20, 2022 · 1953 views
    This topic created in 1338 days ago, the information mentioned may be changed or developed.
    		<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 这样写好像不对。

    linkopeneyes
        1
    linkopeneyes  
       Sep 20, 2022
    把 style 写成变量 直接:style="style" ? 好久没写小程序忘记语法了
    yaphets666
        2
    yaphets666  
       Sep 20, 2022
    :style="'background-image: url'+({{img_back.img}})+';height: 414upx;'"
    yaphets666
        3
    yaphets666  
       Sep 20, 2022
    上面多了两个大括号,:style="'background-image: url('+img_back.img+');height: 414upx;'"
    Danswerme
        4
    Danswerme  
       Sep 20, 2022
    :style="`background-image: url(${img_back.img});height: 414upx;`"
    chunhai
        5
    chunhai  
    OP
       Sep 21, 2022
    @yaphets666 懂了懂了,感谢哈哈
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1007 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 60ms · UTC 22:20 · PVG 06:20 · LAX 15:20 · JFK 18:20
    ♥ Do have faith in what you're doing.