UNPKG

@ccos/webos-vue

Version:

A Web-Ui Framework for Skyworth/Coocaa TV

77 lines (76 loc) 2.63 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const vue = require("vue"); require("./index39.js"); const _pluginVue_exportHelper = require("./index34.js"); const _withScopeId = (n) => (vue.pushScopeId("data-v-eb2824ea"), n = n(), vue.popScopeId(), n); const _hoisted_1 = { class: "m-switch-wrap" }; const _hoisted_2 = { class: "switch-inner" }; const _hoisted_3 = ["checked", "true-value", "false-value"]; const _hoisted_4 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("span", { class: "d-switch_action" }, null, -1)); const _sfc_main = { __name: "switch", props: { modelValue: { //绑定值 type: [Number, String, Boolean] }, activeValue: { //switch 打开时的值 可以自定义组件打开的时的值 type: [Number, String, Boolean], default: true }, inactiveValue: { // switch 关闭时的值 可以自定义组件关闭的时的值 type: [Number, String, Boolean], default: false }, text: { type: String, default: "" }, disabled: { type: Boolean, default: false } }, emits: ["update:modelValue", "change"], setup(__props, { emit: __emit }) { const props = __props; const emits = __emit; const input = vue.ref(null); const checked = vue.computed(() => { return props.modelValue === props.activeValue; }); const handleInput = () => { vue.nextTick(() => { const val = input.value.checked; console.log("val=====>", val); emits("update:modelValue", val); emits("change", val); }); }; return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [ vue.createElementVNode("div", _hoisted_2, vue.toDisplayString(__props.text), 1), vue.createElementVNode("div", { class: vue.normalizeClass(["d-switch", { "is-checked": checked.value, " disabled": __props.disabled }]) }, [ vue.createElementVNode("input", { class: "d-switch__input", ref_key: "input", ref: input, type: "checkbox", checked: checked.value, onChange: handleInput, "true-value": __props.activeValue, "false-value": __props.inactiveValue }, null, 40, _hoisted_3), _hoisted_4 ], 2) ]); }; } }; const TvSwitch = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-eb2824ea"]]); exports.default = TvSwitch;