Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

如何在vue多重列表渲染里使用codePoinAt()

new Vue({
    el:"#view",
    data:{
        dj:['基阿萨大大','留个脚印','空间和萨']
    }
})

<p id="view" v-for="i in dj">
    <a :href="['http://xxx/dict/' + i.codePointAt(c).toString(16)]" v-for="c in i">{{c}}</a>
</p>

需要在 <a> href里对每个字转成16进制值,但如上只能得到每行的第一个字的值,要如何才能实现第个字对应16进制的值呐?

例如:

<p>
    <a href="http://xxx/dict/57fa">基</a>
    <a href="http://xxx/dict/963f">阿</a>
</p>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
<p id="view" v-for="i in dj" :key="i">
    <a style="display:block"
       v-for="(c,index) in i"
          :key="index"
          :href="['http://xxx/dict/' + i.codePointAt(c).toString(16)]"
          >{{ c }}</a
        >
</p>

图片.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...