请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

SFC 新语法错误

用sfc 新语法写 报语法错误 cannot read property ‘content’ of null 这个问题该怎么解决 已经更新 vue upgrade

正在回答 回答被采纳积分+3

2回答

NeoRRRR 2021-01-09 23:05:40

可以考虑不使用rfc的写法,可以使用tsx写完实现,也可以使用vue3正式发布的方法实现:

<template>
<input type="text" :value="value" @input="handleChange" />
</template>

<script>
import { defineComponent, toRef } from 'vue'
import { FiledPropsDefine } from '../types'

export default defineComponent({
props: FiledPropsDefine,
setup(props) {
const value = toRef(props, 'value')
const handleChange = (e: any) => {
console.log(e)
props.onChange(e.target.value)
}
return {
handleChange,
value,
}
},
})
</script>

//img1.sycdn.imooc.com/szimg/5ff9c63b09325fcf21361188.jpg

0 回复 有任何疑惑可以回复我~
Jokcy 2021-01-06 22:08:48

你的代码是怎么写的?

0 回复 有任何疑惑可以回复我~
  • <template>
      <input type="text" :value="value" @input="handleChange" />
    </template>
    
    <script lang="ts" setup="props">
    import { ref } from 'vue'
    import { FieldPropsDefine, Schema } from '../types'
    export default {
      props: FieldPropsDefine,
    }
    declare const props: {
      value: any
      onChange: (v: string) => void
      schema: Schema
    }
    export const handleChange = (e: any) => {
      console.log(e)
      props.onChange(e.target.value)
    }
    </script>
    
    Syntax Error: TypeError: Cannot read property 'content' of null
    
    照着您的视频指导写的,您看下,应该是同一个问题
    回复 有任何疑惑可以回复我~ 2021-02-18 01:47:31
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信