ueditor-百度可视化编辑器简单使用方法

1、ueditor是百度可视化编辑工具

 

2、ueditor官网地址

    http://ueditor.baidu.com/website/index.html

 

3、开发步逐

    1、在官网上下载最新版本的jsp版本

图1


    2、将下载的压缩文件解压,改文件夹名称为“ueditor”;

    3、创建“ueditorTest”项目,ueditor添加到项目中;

    4、项目目录如下


 图2

    5、将ueditor\jsp\lib目录下的jar复制到项目lib目录下(这里是做后台配置的jar),然后ueditor\jsp\lib可以删除。

    6、创建”ueditorTest.jsp“页面测试

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>提示</title>
	
	<!--使用ueditor需要导入的js-->
	<script type="text/javascript" src="common/js/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" src="common/js/ueditor/ueditor.all.min.js"></script>
	<script type="text/javascript" src="common/js/ueditor/lang/zh-cn/zh-cn.js"></script>
	
	<style type="text/css">
	    #div_1 {
			border: thin none #069;
			padding: 1px;
			float: none;
			width: 500px;
			height: 300px;
			background-color: #9C6;
		}
    </style>
</head>
<body>
	<!-- 加载编辑器的容器 -->
    	<script id="container" name="content" type="text/plain"> </script>
	<script type="text/javascript">
		//<!-- 实例化编辑器 -->
		var ue = UE.getEditor('container');
		
    	function test(){
    		//获取html内容,返回: <p>hello</p>
   			var html = ue.getContent();
   		 	//获取纯文本内容,返回: hello
			var txt = ue.getContentTxt();
			
			alert(html);
			alert(txt);
    	}
	</script>
	
	<input type="button" value="测试" name="ceshi" onClick="test();"/>
</body>
</html>

   

    效果图:

图3 

    说明:

          1、上传图片、附件、截图存放路径在“ueditor/jsp/config.json”配置,如果没有配置会根据默认配置在工程下自动创建目录;

          2、"ueditor\jsp\controller.jsp",为ueditor配置项入口;

          3、ueditor\jsp\lib存放后台配置的jar,使用是须将该目录下的jar负责到项目中;

 

5、ueditor使用小心得

      1、实例化时设置一些初始话值

// 实例化编辑器
var ue = UE.getEditor('content',{
	initialFrameWidth :590,//设置编辑器宽度
	initialFrameHeight:400,//设置编辑器高度
	scaleEnabled:false
});

      2、直接赋值

<!--必须要在js里初始化编辑器-->
<td align="left" colspan="3">
	<script id="content" name="content" type="text/plain"> 
		${news.content}
	</script>	 			
</td>

    3、关闭编辑其自动增长,在ueditor.config.js配置文件中将autoHeightEnabled: true 修改为false即可。
                                                                                                图6

    

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
为了禁止vue-ueditor-wrap富文本编辑器的编辑功能,你可以在使用组件的地方加上一个属性来禁用编辑。根据引用和引用中的代码,你可以在main.js和App.vue中添加以下代码: 在main.js中: ``` import VueUeditorWrap from 'vue-ueditor-wrap' Vue.component('vue-ueditor-wrap', { ...VueUeditorWrap, props: { disabled: { type: Boolean, default: false } }, mounted: function() { if (this.disabled) { this.$refs.ueditor.setDisabled() } } }) new Vue({ render: h => h(App), }).$mount('#app') ``` 在App.vue中: ``` <template> <div id="app"> <VueUeditorWrap :disabled="true"></VueUeditorWrap> </div> </template> <script> import VueUeditorWrap from 'vue-ueditor-wrap' export default { components: { VueUeditorWrap } } </script> ``` 这样设置之后,vue-ueditor-wrap富文本编辑器就会被禁用,用户将无法编辑其中的内容。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [vue-ueditor-wrap百度富文本的使用](https://blog.csdn.net/qq_52883064/article/details/129875979)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [vue项目引入vue-ueditor-wrap富文本编辑器](https://blog.csdn.net/weixin_45966674/article/details/123498254)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值