如何使用百度富文本

效果图:

使用代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>富文本编辑器示例</title>
    <script src="js/jquery-3.6.3.js"></script>
  <script src="./fuwenben/ueditor.config.js"></script>
  <script src="fuwenben/ueditor.all.min.js"></script>
  <script src="fuwenben/lang/zh-cn/zh-cn.js"></script>
</head>
<style>
	.box{
		width: 100%;
		height: 50%;
	}
</style>

<body>
   
   <div class="box">
	   <!-- 富文本 -->
	   <textarea id="contents" name="contents" style="overflow:scroll;margin-top: 2%;width: 100%;height: 300px;"></textarea>
	  
   </div>
   <script>
	   // 富文本
	   let ou = UE.getEditor('contents', {
	   	initialFrameWidth: 500,
	   	initialFrameHeight: 400,
	   });
   </script>
</body>
</html>

这是一个简单的富文本;

希望可以帮到大家

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Vue项目中使用百度富文本编辑器UEditor,您可以按照以下步骤操作: 1. 安装UEditor 您可以通过npm安装UEditor: ``` npm install vue-ueditor-wrap --save ``` 2. 引入UEditor 在需要使用UEditor的Vue组件中引入UEditor: ```javascript import VueUeditorWrap from 'vue-ueditor-wrap'; ``` 3. 注册组件 在Vue组件中注册UEditor组件: ```javascript export default { components: { VueUeditorWrap }, // ... } ``` 4. 使用UEditor 在Vue模板中使用VueUeditorWrap组件: ```html <vue-ueditor-wrap ref="editor" :config="editorConfig" @ready="onEditorReady" @content-change="onContentChange" ></vue-ueditor-wrap> ``` 其中,config属性是UEditor的配置项,可以在Vue组件中定义: ```javascript editorConfig: { serverUrl: '/server_url', // UEditor服务器接口地址 UEDITOR_HOME_URL: '/static/UEditor/', // UEditor资源文件所在路径 // ...其他UEditor配置项 } ``` ready事件会在UEditor初始化完成后触发,您可以在事件处理函数中获取UEditor实例: ```javascript onEditorReady(editor) { this.ueditor = editor; } ``` content-change事件会在UEditor内容发生变化时触发,您可以在事件处理函数中获取UEditor内容: ```javascript onContentChange() { const content = this.ueditor.getContent(); } ``` 5. 打包UEditor资源文件 最后,您还需要将UEditor的资源文件打包到您的Vue项目中,以便在浏览器中加载。可以通过webpack的copy-webpack-plugin插件实现: ```javascript const CopyWebpackPlugin = require('copy-webpack-plugin'); module.exports = { // ... plugins: [ new CopyWebpackPlugin([ { from: 'node_modules/vue-ueditor-wrap/UEditor/', to: 'static/UEditor/' } ]) ] }; ``` 这样就可以在Vue项目中使用UEditor了。具体的使用方法可以参考UEditor官方文档和vue-ueditor-wrap插件文档。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值