技术标签: Vue知识雨
执行如下命令来进行插件安装:
npm install vue-html5-editor -S
我们还需要安装font-awesome ,因为里面使用到的图标是基于font-awesome的,需要执行如下命令:
npm install font-awesome --save
新建工具类initHTMLEditor.js文件,主要用于初始化我们的vue-html5-editor,js代码如下:
import Vue from 'vue'
import VueHtml5Editor from 'vue-html5-editor'
export default function () {
let opt = {
// 全局组件名称,使用new VueHtml5Editor(options)时该选项无效
name: "vue-html5-editor",
// 是否显示模块名称,开启的话会在工具栏的图标后台直接显示名称
showModuleName: true,
// 自定义各个图标的class,默认使用的是font-awesome提供的图标
icons: {
text: "fa fa-pencil",
color: "fa fa-paint-brush",
font: "fa fa-font",
align: "fa fa-align-justify",
list: "fa fa-list",
link: "fa fa-chain",
unlink: "fa fa-chain-broken",
tabulation: "fa fa-table",
image: "fa fa-file-image-o",
hr: "fa fa-minus",
eraser: "fa fa-eraser",
undo: "fa-undo fa",
"full-screen": "fa fa-arrows-alt",
info: "fa fa-info",
},
// 配置图片模块
image: {
// 文件最大体积,单位字节
sizeLimit: 512 * 1024 * 10,
// 上传参数,默认把图片转为base64而不上传
// upload config,default null and convert image to base64
upload: {
url:null,
headers:{
},
params: {
},
fieldName:{
}
},
// 压缩参数,默认使用localResizeIMG进行压缩,设置为null禁止压缩
// width和height是文件的最大宽高
compress: {
width: 600,
height: 600,
quality: 80
},
// 响应数据处理,最终返回图片链接
uploadHandler(responseText){
// default accept json data like {ok:false,msg:"unexpected"} or {ok:true,data:"image url"}
var json = JSON.parse(responseText);
if(json.status == 200){
return json.data
}else{
alert(json.error)
}
}
},
// 语言,内建的有英文(en-us)和中文(zh-cn)
language: "zh-cn",
// 自定义语言
i18n: {
"zh-cn": {
"align": "对齐方式",
"image": "图片",
"list": "列表",
"link": "链接",
"unlink": "去除链接",
"table": "表格",
"font": "文字",
"full screen": "全屏",
"text": "排版",
"eraser": "格式清除",
"info": "关于",
"color": "颜色",
"please enter a url": "请输入地址",
"create link": "创建链接",
"bold": "加粗",
"italic": "倾斜",
"underline": "下划线",
"strike through": "删除线",
"subscript": "上标",
"superscript": "下标",
"heading": "标题",
"font name": "字体",
"font size": "文字大小",
"left justify": "左对齐",
"center justify": "居中",
"right justify": "右对齐",
"ordered list": "有序列表",
"unordered list": "无序列表",
"fore color": "前景色",
"background color": "背景色",
"row count": "行数",
"column count": "列数",
"save": "确定",
"upload": "上传",
"progress": "进度",
"unknown": "未知",
"please wait": "请稍等",
"error": "错误",
"abort": "中断",
"reset": "重置"
}
},
// 隐藏不想要显示出来的模块
hiddenModules: [],
// 自定义要显示的模块,并控制顺序
visibleModules: [
// "text",
// "color",
"font",
"align",
// "list",
// "link",
// "unlink",
// "tabulation",
"image",
// "hr",
// "eraser",
"undo",
// "full-screen",
// "info",
],
// 扩展模块,具体可以参考examples或查看源码
// extended modules
modules: {
//omit,reference to source code of build-in modules
}
};
Vue.use(VueHtml5Editor, opt);
}
我们还需要再main.js中引入这个初始化的函数和刚刚的font-awesome相关样式文件,如下:
import initRichText from './api/initHTMLEditor.js'
import 'font-awesome/css/font-awesome.min.css'
使用方法如下:
<template>
<div>
<p>
<button type="button" @click="focus">focus</button>
<button type="button" @click="fullScreen">full screen</button>
<button type="button" @click="showModuleName=!showModuleName">toggle module name</button>
<button type="button" @click="reset">change content</button>
<span style="white-space: nowrap">content length : {
{
content.length}}</span>
</p>
<vue-html5-editor :content="content" :height="300" :show-module-name="showModuleName"
@change="updateData" ref="editor"></vue-html5-editor>
</div>
</template>
<script>
export default {
name: 'htmlEditor',
data () {
return {
content: "<h3>vue html5 editor</h3>",
showModuleName: false,
}
},
props: {
},
watch: {
},
mounted () {
},
methods: {
updateData: function (data) {
// sync content to component
this.content = data
},
fullScreen: function () {
this.$refs.editor.enableFullScreen()
},
focus: function () {
this.$refs.editor.focus()
},
reset:function () {
var newContent = prompt('please input some html code: ')
if(newContent){
this.content = newContent
}
}
},
destroyed () {
}
}
</script>
<style scoped>
.color{
color:red
}
</style>
文章浏览阅读714次。A - 18岁生日Gardon的18岁生日就要到了,他当然很开心,可是他突然想到一个问题,是不是每个人从出生开始,到达18岁生日时所经过的天数都是一样的呢?似乎并不全都是这样,所以他想请你帮忙计算一下他和他的几个朋友从出生到达18岁生日所经过的总天数,让他好来比较一下。 Input一个数T,后面T行每行有一个日期,格式是YYYY-MM-DD。如我的生日是1988-03-07。_g最近想给女友送两个精美的小礼品:两个底面半径分别为r1和r2的圆柱形宝石,并想装
文章浏览阅读2k次。HUAWEI华为笔记本平板电脑MateBook E 2019款 高通850版8GB+256GB(PAK-AL09)原装出厂WIN10ARM系统恢复原厂系统1809。_pak-al09 怎么装系统
文章浏览阅读3w次,点赞10次,收藏53次。api参考:fillna:使用指定的方法填充 NA/NaN 值。>>> df = pd.DataFrame([[np.nan, 2, np.nan, 0], [3, 4, np.nan, 1], [np.nan, np.nan, np.nan, 5], [np.nan, 3, np.nan, 4]], columns=list._pandas fillna
文章浏览阅读3.2k次。AI视频标注工具,可以用于分割、分类、行为的视频标注工具_视频标注工具
文章浏览阅读842次。HttpClientFactory与gRPC_grpc httpclientfactory
文章浏览阅读768次,点赞13次,收藏13次。PMP的考证成本是由 考试费+培训费组成,考试费是固定的3900元(如一次没过,补考费2500元),培训费根据自己选择的PMP培训机构而定,目前我们能够选择的机构比较多,同时也是各有千秋,价格也是从2500-3500元不等,我选择的机构是威班PMP,通过率高,教的不错,并且价格也便宜,活动上1600多入手(好像近期也有),恢复原价后是2298元,个人体验不错,也推荐大家选择这一类性价比高的机构。老师教的不错,课程质量又高,通过率不高才是奇怪的事情。
文章浏览阅读1.2w次,点赞8次,收藏16次。原因一:keras的后端是theano,默认channels_first,即他的图像形状是input_shape=(img_channels,img_rows, img_cols )。而在tensorflow中则是默认channels_last,即input_shape=(img_rows, img_cols, img_channels)。解决方法:可添加这两行代码,使其变为ch..._valueerror: negative dimension size caused by subtracting 3 from 2 for '{{no
文章浏览阅读1.8k次。在Linux中自动运行程序有以下几种方式:1.开机启动时自动运行程序 Linux加载后, 它将初始化硬件和设备驱动, 然后运行第一个进程init。init根据配置文件继续引导过程,启动其它进程。通常情况下,修改放置在 /etc/rc或 /etc/rc.d 或 /etc/rc?.d 目录下的脚本文件,可以使init自动启动其它程序。例如:编辑 /etc/rc.d/rc.local 文件,在文件
文章浏览阅读1.9k次,点赞2次,收藏10次。进来踩坑吧_bootstrap怎么全局加载
文章浏览阅读808次。Spring:AOP面向方面编程、IoC控制反转、事务、Bean是构成应用进程主干、由IoC容器创建的对象。_j2ee和ssm
文章浏览阅读2.1k次。1x1卷积核虽然不能进行上/下采样,但在CNN中仍有很重要的作用1x1卷积核的作用升维、降维首先一个很简单的例子,feature map 大小为16x16 channel = 8,通过一个1x1 数量为4的卷积核,得到的输出就为16x16x4降维最明显的影响就是增加了网络的深度,但是并不会增加网络的参数量,通过不同大小卷积核的组合,同时也可以大幅度减小计算量输入56 * 56 * 192,使用5 * 5 * 32的卷积核。最终的计算量是:56 * 56 * 32 * 5 * 5 * 192 _如何扩展卷积核使其尺寸为16*16
文章浏览阅读1.1k次。webpack打包,突然报错this.getOptions is not a function?是不是像这种报错?是不是偷偷下载loader了?这种问题一般就是该loader版本过高了,可以换个低版本的,可以去npm里面找找该loader的低版本,反正我都是这么解决的写这篇文章,目的是为了纪念因为这个错误纠结好久的日子,顺道希望可以帮到你,要是还解决不了,可以联系作者..._webpack this.getoptions is not a function