有人能解释为什么会发生这种情况吗?刚接触Vue,不知道出了什么问题?
这是可行的:
<template>
<div>
...
<div v-else>
{{ remaining.hours > 0 ? (remaining.hours < 10 ? '0' : '') + remaining.hours + ':' : '' }}然而,当我尝试添加一个span时,我得到了'unclosed string literal‘错误:
<template>
<div>
...
<div v-else>
{{ remaining.hours > 0 ? (remaining.hours < 10 ? '0' : '') + remaining.hours + '<span class="colon">:</span>' : '' }}发布于 2020-04-06 03:19:49
花括号将数据解释为纯文本。对于HTML,使用v-html指令:
<div v-else v-html="remainingHtml">computed : {
remainingHtml () {
return remaining.hours > 0 ? (remaining.hours < 10 ? '0' : '') + remaining.hours + '<span class="colon">:</span>' : '' :
}
}https://stackoverflow.com/questions/61047201
复制相似问题