阅读以下代码,请选择可以正确打印h1标签宽度的选项( )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<
template
>
<
div
>
<h1 ref=
'h1'
v-
if
=
"show"
>nowcoder</h1>
</
div
>
</
template
>
<script>
export
default
{
data() {
return
{
show:
false
}
},
mounted() {
this
.show =
true
// 此处填写代码
}
}
</script>
this.$nextTick(function() {console.log(this.$refs.h1.offsetWidth)
})
setInterval(() => {console.log(this.$refs.h1.offsetWidth)
})
setTimeout(() => {console.log(this.$refs.h1.offsetWidth)
})
console.log(this.$refs.h1.offsetWidth)
有如下代码,最终渲染出来的div元素的class属性值是( )
有如下模板:
1
2
3
4
<
div
class
=
"static"
v-bind:
class
=
"{ active: isActive, 'text-danger': hasError }"
></
div
>
和如下data:
1
2
3
4
data: {
isActive:
true
,
hasError:
false
}
static isActivestatic activestatic hasErrorisActive
以下选项中不可以进行路由跳转的是( )
this.$router.jump()route-linkthis.$router.push()this.$router.replace()
关于Vue组件的生命周期说法错误的是( )
mounted钩子函数中,可以直接获取DOM元素beforeMount钩子函数中,不可以直接获取DOM元素beforeDestroy钩子函数中,不可以直接获取DOM元素destroyed钩子函数中,不可以直接获取DOM元素
关于Vue组件生命周期说法错误的是( )
Vue组件的生命周期可以分成三个大阶段:挂载、更新、卸载挂载阶段中涉及到的钩子函数有:beforeCreate、created、beforeMount、mounted更新阶段涉及的钩子函数有:beforeUpdate、updated、activated、deactivated首次进入页面钩子函数的执行顺序:beforeCreate、created、beforeMount、mounted
以下不是vue内置指令的是( )
v-htmlv-onv-forv-hidden