@capchen/nutui-taro
Version:
京东风格的轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)
72 lines (71 loc) • 2.41 kB
JavaScript
import { getCurrentInstance, h, defineComponent, reactive, toRefs, resolveComponent, openBlock, createElementBlock, Fragment, createBlock, normalizeProps, mergeProps, withCtx, renderSlot, createCommentVNode, createTextVNode } from "vue";
import Taro from "@tarojs/taro";
import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
function useForwardRef() {
var instance = getCurrentInstance();
function forwardRef(ref) {
instance.exposed = ref;
instance.exposeProxy = ref;
}
return forwardRef;
}
const taroScrollView = {
emits: ["tap", "scroll"],
setup: function setup(props, _ref) {
var slots = _ref.slots, emit = _ref.emit, attrs = _ref.attrs;
var forwardRef = useForwardRef();
return function() {
return h("taro-scroll-view-core", {
ref: forwardRef,
class: ["hydrated", {
"taro-scroll-view__scroll-x": attrs["scroll-x"] === "",
"taro-scroll-view__scroll-y": attrs["scroll-y"] === ""
}],
onClick: function onClick(e) {
emit("tap", e);
},
onScroll: function onScroll(e) {
if (e instanceof CustomEvent) {
emit("scroll", e);
}
}
}, slots);
};
}
};
const ScrollView = "scroll-view";
const _sfc_main = defineComponent({
name: "NutScrollView",
components: {
ScrollView,
taroScrollView
},
setup() {
const state = reactive({
ENV: Taro.getEnv(),
ENV_TYPE: Taro.ENV_TYPE
});
return {
...toRefs(state)
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_taro_scroll_view = resolveComponent("taro-scroll-view");
return openBlock(), createElementBlock(Fragment, null, [
_ctx.ENV == _ctx.ENV_TYPE.WEB ? (openBlock(), createBlock(_component_taro_scroll_view, normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
default: withCtx(() => [
renderSlot(_ctx.$slots, "default")
]),
_: 3
}, 16)) : createCommentVNode("", true),
createTextVNode(),
_ctx.ENV != _ctx.ENV_TYPE.WEB ? (openBlock(), createElementBlock("scroll-view", normalizeProps(mergeProps({ key: 1 }, _ctx.$attrs)), [
renderSlot(_ctx.$slots, "default")
], 16)) : createCommentVNode("", true)
], 64);
}
const NutScrollView = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
NutScrollView as N
};