浏览代码

fix: 获取 dom

Ymm0008 4 年之前
父节点
当前提交
ca5ee6c1b1

+ 2 - 2
package.json

@@ -72,6 +72,7 @@
   "devDependencies": {
     "@commitlint/cli": "^10.0.0",
     "@commitlint/config-conventional": "^10.0.0",
+    "@tarojs/taro": "3.3.0-alpha.6",
     "@types/jest": "^26.0.22",
     "@types/node": "^14.14.31",
     "@vitejs/plugin-legacy": "^1.4.0",
@@ -97,8 +98,7 @@
     "typescript": "^4.1.5",
     "vite": "^2.3.4",
     "vite-plugin-md": "^0.6.7",
-    "vue-jest": "^5.0.0-alpha.7",
-    "@tarojs/taro": "3.3.0-alpha.6"
+    "vue-jest": "^5.0.0-alpha.7"
   },
   "eslintConfig": {
     "root": true,

+ 0 - 10
src/config.json

@@ -580,7 +580,6 @@
         },
         {
           "version": "3.0.0",
-<<<<<<< HEAD
           "name": "TextArea",
           "type": "component",
           "cName": "文本域",
@@ -588,15 +587,6 @@
           "sort": 7,
           "show": true,
           "author": "gx"
-=======
-          "name": "CountUp",
-          "type": "component",
-          "cName": "数字滚动",
-          "desc": "数字滚动,可自定义图片,可模拟抽奖",
-          "sort": 7,
-          "show": true,
-          "author": "Ymm0008"
->>>>>>> 50ee824b330a60b0784a5fd9b0c71c44ef7aaf2e
         }
       ]
     },

+ 18 - 0
src/packages/__VUE/collapseitem/index.taro.vue

@@ -58,6 +58,10 @@ import {
   getCurrentInstance,
   ComponentInternalInstance
 } from 'vue';
+import Taro, {
+  eventCenter,
+  getCurrentInstance as getCurrentInstanceTaro
+} from '@tarojs/taro';
 import { createComponent } from '@/packages/utils/create';
 const { create, componentName } = createComponent('collapse-item');
 
@@ -180,6 +184,7 @@ export default create({
     const currentName = computed(() => props.name);
     const toggleOpen = () => {
       console.log('点击了——————-----');
+      console.log(document.getElementsByClassName('collapse-content')[0]);
 
       if (parent.props.accordion) {
         parent.children.forEach((item: any, index: number) => {
@@ -232,6 +237,19 @@ export default create({
         }
       }
 
+      // 获取 DOM 元素
+      eventCenter.once((getCurrentInstanceTaro() as any).router.onReady, () => {
+        let a = document.getElementsByClassName('collapse-wrapper')[0];
+        console.log(a);
+
+        // const query = Taro.createSelectorQuery()
+        // query.select('.collapse-wrapper').boundingClientRect()
+        // query.exec(res => {
+        //   console.log(res, 'res')
+        // })
+        // console.log('onReady')
+      });
+
       // proxyData.classDirection = parent.props.expandIconPosition;
       // if (parent.props.icon && parent.props.icon != 'none') {
       //   proxyData.iconStyle['background-image'] =

+ 2 - 2
src/sites/mobile-taro/vue/src/pages/collapse/index.vue

@@ -3,10 +3,10 @@
     <h2>基本用法</h2>
     <nut-collapse v-model:active="active1" icon="down-arrow">
       <nut-collapse-item :title="title1" :name="1">
-        <view>京东“厂直优品计划”首推“政府优品馆” 3年覆盖80%镇级政府</view>
+        京东“厂直优品计划”首推“政府优品馆” 3年覆盖80%镇级政府
       </nut-collapse-item>
       <nut-collapse-item :title="title2" :name="2">
-        <view>京东到家:教师节期间 创意花束销量增长53倍</view>
+        京东到家:教师节期间 创意花束销量增长53倍
       </nut-collapse-item>
       <nut-collapse-item :title="title3" :name="3" disabled>
       </nut-collapse-item>

+ 1 - 1
vite.config.build.taro.vue.ts

@@ -26,7 +26,7 @@ export default defineConfig({
   build: {
     rollupOptions: {
       // 请确保外部化那些你的库中不需要的依赖
-      external: ['vue', 'vue-router'],
+      external: ['vue', 'vue-router', '@tarojs/taro'],
       output: {
         banner,
         // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量