亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

有一個簡單的問題

我想讓兩個button的顏色不一樣使用{{color}}這個形式進行連接,但是得不到想要變化的顏色。


代碼如下:

<!DOCTYPE html>

<html>


<head>

? <meta charset="text/html;charset=utf-8">

? <title>Vue js</title>

? <script src="https://unpkg.com/vue"></script>

? <link rel="stylesheet" href="main.css">

</head>


<body>

<div id="app">

? <counter heading="贊" color="green"></counter>

? <counter heading="滾"></counter>

??

</div>


<template id="counter-template">

? <div>

? <h1>{{heading}}</h1>

? <button @click="count+=1" style="background: {{color}}">{{count}}</button>

</div>

</template>

<script>

? Vue.component('counter',{

? ? template:'#counter-template',

? ? props:['heading','color'],

? ? data:function(){

? ? ? return{count:0};

? ? }

? });

? new Vue({

? ? el:'#app'

? })


</script>

</body>


</html>


正在回答

1 回答

<button @click="count+=1"

:style="{background:color}

">{{count}}</button>

1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

有一個簡單的問題

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號