第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

vue函數(shù)式組件中的render函數(shù)如何添加偽類樣式

vue函數(shù)式組件中的render函數(shù)如何添加偽類樣式

紫衣仙女 2019-03-15 18:14:35
問(wèn)題描述export default {    functional: true,    props: {        data: {            type: String,            default() {                return '';            }        },        depth: {            type: Number        }    },    render: (h, ctx) => {        return h('div', {            class: ['treeitem'],            style: {                ':hover': {                    background: 'yellow'  // 希望在div這個(gè)元素上添加一個(gè)偽類的樣式,但是沒(méi)有效果                },                height: '40px',                lineHeight: '40px',                border: '1px solid #f0f0f0',                'marginLeft': ctx.props.depth*20 + 'px'            },            on: {                click: () => {                },                mouseover: () => {                }            }        }, [            h('Icon', {                props: {                    type: 'arrow-right-b',                },                style: {                    marginLeft: '20px',                    display: 'inline-block',                    width: '40px',                    hight: '40px'                }            }),            h('span',{                style: {                }            }, ctx.props.data),            h('Button', {                props: {                    icon: 'ios-gear-outline'                },                style: {                    float: 'right'                 },                on: {                    click: () => {                    }                }            })        ]);    }}問(wèn)題出現(xiàn)的環(huán)境背景及自己嘗試過(guò)哪些方法嘗試為div元素添加class,但是作為函數(shù)式組件,這個(gè)是js文件,style該寫在哪里?相關(guān)代碼// 請(qǐng)把代碼文本粘貼到下方(請(qǐng)勿用圖片代替代碼)你期待的結(jié)果是什么?實(shí)際看到的錯(cuò)誤信息又是什么?
查看完整描述

3 回答

?
慕妹3242003

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超6個(gè)贊

這不是 vue 的問(wèn)題,目前行內(nèi)樣式是不支持寫偽類的


可以嘗試在 head 中添加一個(gè) style 標(biāo)簽


const styleEl = document.createElement('style')

styleEl.innerHTML = `

  .treeitem:hover{

    background: yellow;

  }

`

document.head.appendChild(styleEl)


查看完整回答
反對(duì) 回復(fù) 2019-04-10
?
慕哥6287543

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超10個(gè)贊

推薦綁定到class上


查看完整回答
反對(duì) 回復(fù) 2019-04-10
?
BIG陽(yáng)

TA貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個(gè)贊

推薦通過(guò)class來(lái)操作,然后通過(guò)class選中偽類


查看完整回答
反對(duì) 回復(fù) 2019-04-10
  • 3 回答
  • 0 關(guān)注
  • 2843 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)