提交 5df36a83 编写于 作者: 雪洛's avatar 雪洛

fix(uni-app-x web): 移除ssr时对HTMLElement的引用

上级 378fec45
...@@ -73,10 +73,12 @@ export default /*#__PURE__*/ defineBuiltInComponent({ ...@@ -73,10 +73,12 @@ export default /*#__PURE__*/ defineBuiltInComponent({
name: 'Switch', name: 'Switch',
props, props,
emits: ['change'], emits: ['change'],
//#if _X_ && !_NODE_JS_
rootElement: { rootElement: {
name: 'uni-switch', name: 'uni-switch',
class: UniSwitchElement, class: UniSwitchElement,
}, },
//#endif
setup(props, { emit }) { setup(props, { emit }) {
const rootRef = ref<HTMLElement | null>(null) const rootRef = ref<HTMLElement | null>(null)
const switchChecked = ref(props.checked) const switchChecked = ref(props.checked)
...@@ -117,6 +119,8 @@ export default /*#__PURE__*/ defineBuiltInComponent({ ...@@ -117,6 +119,8 @@ export default /*#__PURE__*/ defineBuiltInComponent({
checkedCache.value = val checkedCache.value = val
} }
) )
//#if _X_ && !_NODE_JS_
onMounted(() => { onMounted(() => {
const rootElement = rootRef.value as UniSwitchElement const rootElement = rootRef.value as UniSwitchElement
Object.defineProperty(rootElement, 'checked', { Object.defineProperty(rootElement, 'checked', {
...@@ -129,6 +133,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({ ...@@ -129,6 +133,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
}) })
rootElement.attachVmProps(props) rootElement.attachVmProps(props)
}) })
//#endif
return () => { return () => {
const { const {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册