这是我的Html模板
我是惯性js的新手,我正在尝试用"提交"方法提交数据我不知道为什么它没有定义
<script>
import AppLayout from '@/Layouts/AppLayout'
//import Welcome from '@/Jetstream/Welcome'
export default {
components: {
AppLayout,
},
data(){
return{
reactive:true,
form:{
course_title: null,
about:null
}
}
},
method: {
submit(){
const data =new FormData()
data.append('course_title', this.form.course_title || '')
data.append('about', this.form.about|| '')
this.$inertia.post(this.route('createcourse'),data)
}
}
}
这是我的脚本:
`从"@/Layments/AppLayout"导入AppLayout//从"@/Jetstream/Welcome"导入欢迎
export default {
components: {
AppLayout,
},
data(){
return{
reactive:true,
form:{
course_title: null,
about:null
}
}
},
method: {
submit(){
const data =new FormData()
data.append('course_title', this.form.course_title || '')
data.append('about', this.form.about|| '')
this.$inertia.post(this.route('createcourse'),data)
}
}
}
`
在组件的脚本部分将method
更改为methods
<script>
import AppLayout from '@/Layouts/AppLayout'
//import Welcome from '@/Jetstream/Welcome'
export default {
components: {
AppLayout,
},
data(){
return{
reactive:true,
form:{
course_title: null,
about:null
}
}
},
methods: { //fix the typo here
submit(){
const data =new FormData()
data.append('course_title', this.form.course_title || '')
data.append('about', this.form.about|| '')
this.$inertia.post(this.route('createcourse'),data)
}
}
}
</script>