Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
swx_weapp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2022-10-26 18:58:25 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c7d32bc40dfcc4caa1b4b9b508f74bc3032a2592
c7d32bc4
1 parent
dadaaece
fix 富文本编辑器写入数据逻辑调整
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
9 deletions
src/components/activity-editor.vue
src/components/activity-editor.vue
View file @
c7d32bc
<!--
* @Date: 2022-09-26 21:52:25
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-26 1
1:31:30
* @LastEditTime: 2022-10-26 1
8:54:14
* @FilePath: /swx/src/components/activity-editor.vue
* @Description: 文件描述
-->
...
...
@@ -56,28 +56,41 @@ import { ref } from 'vue'
<script>
import Taro from '@tarojs/taro'
import BASE_URL from '@/utils/config';
import { activityInfoAPI } from '@/api/Host/index';
import { getCurrentPageParam } from "@/utils/weapp";
export default {
props: ['showTabBar', 'placeholder', 'name', 'htmlContent'],
data() {
return {
editorCtx: ''
editorCtx: '',
html_content: ''
}
},
watch: {
htmlContent (val) {
async
htmlContent (val) {
// 如果有传值,还原重新编辑
this.editorCtx.setContents({
html: val
})
if (val) {
const { code, data } = await activityInfoAPI({ i: getCurrentPageParam().id });
if (code) {
// 更新活动信息
this.html_content = data.activity.note
this._onEditorReady()
}
}
}
},
methods: {
_onEditorReady: function () {
const that = this;
Taro.createSelectorQuery().select('#editor').context(function (res) {
that.editorCtx = res.context
}).exec();
setTimeout(() => {
wx.createSelectorQuery().select('#editor').context(function (res) {
that.editorCtx = res.context;
that.editorCtx.setContents({
html: that.html_content //将数据写入编辑器内
})
}).exec();
}, 500);
},
//插入图片
_addImage: function (event) {
...
...
@@ -160,6 +173,12 @@ export default {
// this.triggerEvent("input", { html: html, text: text }, {});
// console.warn(html);
// console.warn(text);
},
_rewrite (val) {
// 如果有传值,还原重新编辑
this.editorCtx.setContents({
html: val
})
}
}
}
...
...
Please
register
or
login
to post a comment