vue就地复用原则_在Vue中使用本地HTML输入进行就地编辑

vue就地复用原则

快速编辑 (vue-quick-edit)

In-place editing with native HTML inputs. Inspired by x-editable

使用本地HTML输入进行就地编辑。 受x-editable启发

特征 (Features)

  • [x] In-place editing

    [x]就地编辑

  • [x] Multiple input types

    [x]多种输入类型

  • [x] Native element property bindings

    [x]本机元素属性绑定

  • [x] Theming with CSS overrides or even apply your own classes

    [x]使用CSS进行主题覆盖或什至应用您自己的类

  • [x] Customize with slots

    [x]使用广告位自定义

  • [x] Keyboard support

    [x]键盘支持

  • [ ] Visual feedback when value gets changed or value is invalid

    []值更改或值无效时的视觉反馈

安装 (Install)

$ npm install --save vue-quick-edit

Global include

全局包含

import QuickEdit from 'vue-quick-edit';

Vue.component('quick-edit', QuickEdit);

Local include

本地包含

import QuickEdit from 'vue-quick-edit';

export default {
  components: {
    QuickEdit,
  },
};

用法 (Usage)

<quick-edit v-model="myValue"><quick-edit>

物产 (Properties)

NameTypeDefaultDescription
buttonCancelTextStringCancelThe text on the Cancel button.
buttonOkTextStringOkThe text on the Ok button.
booleanYesTextStringYesThe text for true when you configure type="boolean".
booleanNoTextStringNoThe text for false when you configure type="boolean"
emptyTextStringEmptyThe text to display when there is a falsy value in the v-model directive.
classesObjectSee DescriptionbuttonCancel: 'vue-quick-edit__button--cancel'
buttonOk: 'vue-quick-edit__button--ok'
buttons: 'vue-quick-edit__buttons'
input: 'vue-quick-edit__input'
link: 'vue-quick-edit__link'
wrapper: 'vue-quick-edit'
modeStringokSpecify what the input should do when the user clicks outside of the component. Possible options are ok,cancel or ignore.
optionsArray[]The options to display for a select, checkbox or radio type. This can be an array of strings or an array of objects with text & value as properties.
placeholderValueString''When you pass a placeholder to a select it will display the placeholder as the first default option, you can set the value of this option with placeholderValue.
typeStringinputThis can be input, textarea, select, checkbox, radio, boolean or any other type you can pass to input.
validatorFunctiontrue
v-modelString, Array, Boolean, Number''The value .
名称 类型 默认 描述
buttonCancelText 取消 取消按钮上的文字。
buttonOkText 确定按钮上的文本。
booleanYesText 配置type="boolean"时为true的文本。
booleanNoText 没有 配置type="boolean"时为false的文本
emptyText 空的 v-model指令中的值为伪造时显示的文本。
目的 见描述 buttonCancel:'vue-quick-edit__button--cancel'
buttonOk:'vue-quick-edit__button--ok'
按钮:“ vue-quick-edit__buttons”
输入:“ vue-quick-edit__input”
链接:“ vue-quick-edit__link”
包装器:'vue-quick-edit'
模式 指定当用户在组件外部单击时输入应该执行的操作。 可能的选项是okcancelignore
选项 数组 [] selectcheckboxradio类型显示的选项。 这可以是字符串数组或以textvalue作为属性的对象数组。
占位符值 '' placeholder传递给select时,它将占位符显示为第一个默认选项,您可以使用placeholderValue设置此选项的值。
类型 输入 可以inputtextareaselectcheckboxradioboolean或您可以传递给input任何其他类型。
验证器 功能 真正
模型 字符串,数组,布尔值,数字 '' 价值 。

大事记 (Events)

NameParametersDescription
closeCurrent valueFires when the user has interacted with the "ok" or "close" button.
inputCurrent valueFires when the user has interacted with the "ok" button.
showCurrent valueFires when the user has interacted with the display label.
raw-inputCurrent input valueFires the current input value when the user has interacted with the "ok" button.
名称 参量 描述
当前值 用户与“确定”或“关闭”按钮进行交互时触发。
输入 当前值 用户与“确定”按钮互动时触发。
表演 当前值 用户与显示标签互动时触发。
原始输入 当前输入值 用户与“确定”按钮进行交互时,触发当前输入值。

插槽 (Slots)

NameDefaultDescription
default{{ value || emptyText }}The display value. Available slot props value and raw-value.
button-ok{{ buttonOkText }}A slot to use HTML as a the Ok button text, useful for FontAwesome.
button-cancel{{ buttonCancelText }}A slot to use HTML as the Cancel button text, useful for FontAwesome.
prepend``Prepend HTML before the display text
append``Append HTML after the display text
名称 默认 描述
默认 {{ value || emptyText }} 显示值。 可用的广告位道具valueraw-value
确定 {{ buttonOkText }} 用于将HTML用作“确定”按钮文本的插槽,对FontAwesome有用。
按钮取消 {{ buttonCancelText }} 一个用于将HTML用作“取消”按钮文本的插槽,对FontAwesome有用。
前置 `` 在显示文字之前添加HTML
附加 `` 在显示文字后附加HTML

主题化 (Theming)

自订主题 (Custom theme)

For example just override this class in your style

例如,以您的样式覆盖此类

.vue-quick-edit__link--is-clickable {
  color: #BADA55;
}

引导主题 (Bootstrap theme)

Set up the classes for the corresponding elements

设置相应元素的类

vueQuickEditClasses: {
  wrapper: 'form-group form-inline',
  input: 'form-control input-sm',
  buttons: 'btn-group btn-group-sm',
  buttonOk: 'btn btn-primary',
  buttonCancel: 'btn btn-link',
},

Maybe add specific overrides for bootstrap

也许为引导添加特定的替代

.form-group {
  margin-bottom: 0;
}
.btn-group {
  display: inline-block;
}

Use it like this

这样使用

<quick-edit :classes="vueQuickEditClasses"><quick-edit>

翻译自: https://vuejsexamples.com/in-place-editing-with-native-html-inputs-in-vue/

vue就地复用原则

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值