Pic*_*iao 2 javascript vue.js pug
这是我的组件。
el.focus()插入时确实有效,但我进入[Vue warn]: Property or method "v" is not defined on the instance but referenced during render了控制台。如何去除警告?
<script>
export default {
directives: {
focus: {
inserted (el) {
el.focus()
}
}
}
}
</script>Run Code Online (Sandbox Code Playgroud)
<style lang="stylus" scoped>
input
width: 300px
height: 30px
border: 1px solid #000
</style>
<template lang="jade">
div
input(v-focus)
</template>Run Code Online (Sandbox Code Playgroud)
当你将一个空属性传递给 jade 时,据我所知,它在纯 HTML 中解释的是attribute="attribute". 您的案例中的实际 HTML 是v-focus="v-focus",vue 将其解释为使用v不存在的属性 的表达式。
您可以尝试,input(v-focus="true")因为传递给该指令的值并不重要。
| 归档时间: |
|
| 查看次数: |
2772 次 |
| 最近记录: |