如何解决如何以php形式存储Tiptap编辑器数据?
我想以php形式将TipTap编辑器用作textarea字段。我已经创建了Vue组件并将其传递到刀片视图。
刀片视图:
<form method="post" action="{{ route('dashboard.edit.postInfo',$garage) }}">
@method('PATCH')
@csrf
<div id="app">
<editor content='{{ $garage->description }}'></editor>
</div>
<button type="submit">Save</button>
</form>
我的Vue组件:
<template>
<div class="editor">
<div class="card p-2 mt-1">
<editor-content :editor="editor" />
</div>
</div>
</template>
<script>
import { Editor,EditorContent } from 'tiptap'
export default {
name: "editor",components: {
EditorContent,},props: [
'content'
],data() {
return {
editor: null,}
},mounted() {
this.editor = new Editor({
content: this.content
})
},beforeDestroy() {
// Always destroy your editor instance when it's no longer needed
this.editor.destroy()
},}
</script>
我该怎么做?预先谢谢你。
这是控制台。日志输出:
Editor {…}
activeMarks: (...)
activeNodes: (...)
commands: (...)
defaultOptions: (...)
element: (...)
options: Object
autoFocus: (...)
content: "<p>KFZ Meisterwerkstatt...</p>"
一些lorem ipsum文本要发布
解决方法
尝试使用此绑定:value="editor"
<div class="card p-2 mt-1">
<editor-content :editor="editor" />
<input type="hidden" name="content" :value="editor">
</div>
然后您将在laravel中获得带有数据的content
密钥
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。