当前位置: 首页 > news >正文

钦州建设网站制作个人网站步骤

钦州建设网站,制作个人网站步骤,怎么夸一个网站开发公司,yoast seo当前文档是 wangEditor v4 版本的。 wangEditor v5 已经正式发布#xff0c;可参考文档。 v5 发布之后#xff0c;v4 将不再开发新功能。 介绍 English documentation wangEditor4 —— 轻量级 web 富文本编辑器#xff0c;配置方便#xff0c;使用简单。 官网#…当前文档是 wangEditor v4 版本的。 wangEditor v5 已经正式发布可参考文档。 v5 发布之后v4 将不再开发新功能。 介绍 English documentation wangEditor4 —— 轻量级 web 富文本编辑器配置方便使用简单。 官网www.wangeditor.com文档www.wangeditor.com/v4源码github.com/wangeditor-team/wangEditor 欢迎 star 1npm 安装 wangeditor wangeditor v4 npm i wangeditor --save 基本使用 div iddiv1p欢迎使用 bwangEditor/b 富文本编辑器/p /div script typetext/javascriptconst E window.wangEditorconst editor new E(#div1)editor.create() /script 2构建引入 wangeditor import E from wangeditor 3创建html div refeditorRef/div 根据 ref 设置 编辑器元素高度实例化 wangeditor const editorRef ref() editor new E(editorRef.value) 4配置菜单 默认情况下显示所有菜单 // 配置菜单栏删减菜单调整顺序 editor.config.menus [bold,head,link,italic,underline ] ​ 5图片相关处理 5.1 上传图片限制 editor.config.uploadImgMaxLength 3 5.2 上传图片大小限制 editor.config.uploadImgMaxSize: 10 * 1024 * 1024, // 10M 5.3 请求头的设置 uploadImgServer: props.action, // 配置 server 接口地址 uploadImgHeaders: {Authorization: Bearer ${getPiniaToken()},X-Requested-With: XMLHttpRequest, }, 5.4 上传请求接口 editor.config.customUploadImg function (resultFiles, insertImgFn) {// resultFiles 是 input 中选中的文件列表// insertImgFn 是获取图片 url 后插入到编辑器的方法 ​// 上传图片返回结果将图片插入到编辑器中insertImgFn(imgUrl) } 5.5 上传前的钩子函数 editor.config.uploadImgHooks {// 上传图片之前before: function(xhr) {console.log(xhr) ​// 可阻止图片上传return {prevent: true,msg: 需要提示给用户的错误信息}},// 图片上传并返回了结果图片插入已成功success: function(xhr) {console.log(success, xhr)},// 图片上传并返回了结果但图片插入时出错了fail: function(xhr, editor, resData) {console.log(fail, resData)},// 上传图片出错一般为 http 请求的错误error: function(xhr, editor, resData) {console.log(error, xhr, resData)},// 上传图片超时timeout: function(xhr) {console.log(timeout)},// 图片上传并返回了结果想要自己把图片插入到编辑器中// 例如服务器端返回的不是 { errno: 0, data: [...] } 这种格式可使用 customInsertcustomInsert: function(insertImgFn, result) {// result 即服务端返回的接口console.log(customInsert, result) ​// insertImgFn 可把图片插入到编辑器传入图片 src 执行函数即可insertImgFn(result.data[0])} } 如果使用了 customUploadImg 自定义上传事件那么 wangeditor 其他的图片上传api将会失效例如 uploadImgServer 和 uploadImgHeadersuploadImgHooks 以上都是修改在 editor.config,可以直接在 定义一个对象在editor.config中看自己的需求 6设置是否源码模式 wangeditor 4 不支持源码模式但可以自定义新增菜单 在 wangeditor 中创建 dom,按照官方文档写法如下 constructor(editor: E) {// data-title属性表示当鼠标悬停在该按钮上时提示该按钮的功能简述const $elem $(div classw-e-menu data-title源码i stylefont-style: normal源码/i/div)super($elem, editor)} 给新增的dom菜单添加事件 // 菜单点击事件 clickHandler() {this.switchMode()this.tryChangeActive() } 修改源码模式 enum Mode {// 源码模式Source source,// 实时预览模式Live live, } 上面使用了枚举定义也可以不需要做看自己的使用方式 在这里判断模式状态 this.mode this.isSouceMode() ? Mode.Live : Mode.Source 重新设置编辑器内容 let html this.editor.txt.html() || 切换为源码模式替换内容 使用字符串replace()函数查找字符进行转换输出为源码Html html html.replace(//g, lt;).replace(//g, gt;).replace(/ /g, nbsp;) 源码转换为文本内容 html this.editor.txt.text().replace(/lt;/gi, ).replace(/gt;/gi, ).replace(/nbsp;/gi, ) 菜单激活事件每次切换菜单的时候要调用下wangeditor 方法否则编辑器不知道你当前菜单(扩展)有哪些 tryChangeActive() {if (this.isSouceMode()) {this.active()} else {this.unActive()}} 其他扩展菜单可以参考文档案例https://codepen.io/xiaokyo-the-bold/pen/ZEpWBeo 7案例 扩展菜单class export default class sourceMenu extends BtnMenu {mode Mode.Live ​constructor(editor: E) {const $elem $(div classw-e-menu data-title源码i stylefont-style: normal源码/i/div)super($elem, editor)} ​// 菜单点击事件clickHandler() {this.switchMode()this.tryChangeActive()}tryChangeActive() {if (this.isSouceMode()) {this.active()} else {this.unActive()}} ​isSouceMode() {return this.mode Mode.Source} ​switchMode() {this.mode this.isSouceMode() ? Mode.Live : Mode.Sourcelet html this.editor.txt.html() || if (this.isSouceMode()) {html html.replace(//g, lt;).replace(//g, gt;).replace(/ /g, nbsp;)} else :html this.editor.txt.text().replace(/lt;/gi, ).replace(/gt;/gi, ).replace(/nbsp;/gi, )}this.editor.txt.html(html)} } 在页面加载时初始化wangeditor配置 editor.create()editor.txt.html(props.modelValue) // 初始化重新设置编辑器内容 部分代码 onMounted(() {editor new E(editorRef.value)// 扩展自定义【源码】菜单const sourceMenuKey sourceeditor.menus.extend(sourceMenuKey, sourceMenu)// 配置Object.assign(editor.config, {zIndex: 1,focus: false,height: props.height,menus: [sourceMenuKey, // 源码菜单head,bold,fontSize,fontName,italic,underline,strikeThrough,indent,lineHeight,foreColor,backColor,link,list,todo,justify,quote,emoticon,image,// video, // 移除视频菜单table,code,splitLine,undo,redo,],uploadFileName: file,uploadImgParams: {path: props.path,},uploadImgServer: , // 配置 server 接口地址uploadImgHeaders: {Authorization: token,X-Requested-With: XMLHttpRequest,},// 限制上传的最大图片数量uploadImgMaxLength: 2,// 单个文件的最大体积限制默认为 10MuploadImgMaxSize: 5 * 1024 * 1024, // 5McustomUploadImg: (files: Blob[], insertImgFn: (path: string) void) {try {const imgData new FormData()for (let i in files) {imgData.append(file, files[i])}// 请求接口,并通过   insertImgFn()函数 插入到编辑器中// imgUrl 是从接口返回的图片地址insertImgFn(imgUrl)} catch (error) {message.error(图片上传失败,请重新上传)}}, ​uploadImgHooks: {customInsert: function (insertImgFn: (path: string) void, res: Recordable) {// res即远程请求的response// insertImgFn 可把图片插入到编辑器传入图片 src 执行函数即可insertImgFn(res.data.path as string)},},onchange() {let sourceMenu editor?.menus.menuList.find((item) item.key sourceMenuKey)emit(update:isActive, sourceMenu?.isActive)emit(update:modelValue, editor!.txt.html())},onblur() {lock true},})editor.create()editor.txt.html(‘回显时的内容’) // 初始化重新设置编辑器内容watchEffect(() {props.disabled ? editor?.disable() : editor?.enable()}) }) onBeforeUnmount(() {editor!.destroy()editor null })
http://www.w-s-a.com/news/745715/

相关文章:

  • 龙岗南联网站建设公司江门市
  • 网站运行方案设计平台模式
  • 网站加入wordpress邳州城乡建设局网站
  • 两个网站如何使用一个虚拟主机东莞市网站seo内容优化
  • 湖南网站建设公司排名傲派电子商务网站建设总结
  • 网站建设求职要求互联网挣钱项目平台
  • 网站权重怎么做做黑彩网站能赚钱吗
  • 三台建设局网站网页设计购物网站建设
  • thinkphp大型网站开发市场调研公司招聘
  • 天宁区建设局网站七冶建设集团网站 江苏
  • 越南网站 后缀湘潭新思维网站
  • 环球旅行社网站建设规划书网钛cms做的网站
  • 软件资源网站wordpress不能识别语言
  • 东坑仿做网站西安私人网站
  • 公司想做个网站怎么办如何搭建视频网站
  • .net网站架设凯里网站建设哪家好
  • seo网站建站建站国外百元服务器
  • 家具网站开发设计论文企业网站里面的qq咨询怎么做
  • 网站视频提取软件app淘宝店购买网站
  • 站长之家域名解析做百度推广网站咱们做
  • 行业 网站 方案莱州网站建设公司电话
  • 丹东谁做微网站威海网络科技有限公司
  • 寻找网站建设_网站外包自助打印微信小程序免费制作平台
  • 台式机网站建设vk社交网站做婚介
  • 创建网站得花多少钱网站建设的技术路线
  • 图书馆网站建设汇报免费编程软件哪个好用
  • 手机搭建网站工具网站搜索引擎优化的基本内容
  • 网站快速排名二手交易网站开发技术路线
  • 官方网站开发公司施工企业会计王玉红课后答案
  • 网站建设能用手机制作吗网站建设所需物资