Browse Source

fix(taro): components ref

suzigang 4 years ago
parent
commit
fd79d3a952

+ 3 - 4
package.json

@@ -70,7 +70,6 @@
     "vue-router": "^4.0.4"
   },
   "devDependencies": {
-    "axios": "^0.21.0",
     "@commitlint/cli": "^10.0.0",
     "@commitlint/config-conventional": "^10.0.0",
     "@types/jest": "^26.0.22",
@@ -81,6 +80,7 @@
     "@vue/eslint-config-prettier": "^6.0.0",
     "@vue/eslint-config-typescript": "^5.0.2",
     "@vue/test-utils": "^2.0.0-rc.6",
+    "axios": "^0.21.0",
     "eslint": "^6.7.2",
     "eslint-plugin-prettier": "^3.1.3",
     "eslint-plugin-vue": "^7.0.0-0",
@@ -90,15 +90,14 @@
     "husky": "^6.0.0",
     "jest": "^26.6.3",
     "lint-staged": "^10.5.0",
-    "prettier": "^1.19.1",
+    "prettier": "^2.0.0",
     "standard-version": "^9.3.0",
     "transliteration": "^2.2.0",
     "ts-jest": "^26.5.5",
     "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,

+ 1 - 6
src/packages/__VUE/calendar/index.taro.vue

@@ -43,17 +43,12 @@
 import { PropType, ref } from 'vue';
 import { createComponent } from '@/packages/utils/create';
 const { create } = createComponent('calendar');
-import Popup from './../popup/index.taro.vue';
+import Popup from '@/packages/__VUE/popup/index.taro.vue';
 import CalendarItem from '@/packages/__VUE/calendaritem/index.vue';
-// import CalendarItem from './../calendaritem/index.taro.vue';
 import Utils from '@/packages/utils/date';
 type InputDate = string | string[];
 export default create({
   children: [CalendarItem, Popup],
-  components: {
-    'nut-calendar-item': CalendarItem,
-    'nut-popup': Popup
-  },
   props: {
     type: {
       type: String,

+ 4 - 5
src/packages/__VUE/calendaritem/index.vue

@@ -1,6 +1,6 @@
 <template>
   <view
-    class="nut-calendar .nut-calendar-taro"
+    class="nut-calendar nut-calendar-taro"
     :class="{
       'nut-calendar-tile': !poppable,
       'nut-calendar-nofooter': isAutoBackFill
@@ -493,9 +493,8 @@ export default create({
       requestAniFrame(() => {
         if (weeksPanel?.value && monthsPanel?.value) {
           const top = weeksPanel?.value.getBoundingClientRect().bottom;
-          const monthsDoms = monthsPanel.value.querySelectorAll(
-            '.calendar-month'
-          );
+          const monthsDoms =
+            monthsPanel.value.querySelectorAll('.calendar-month');
           for (let i = 0; i < monthsDoms.length; i++) {
             if (
               monthsDoms[i].getBoundingClientRect().top <= top &&
@@ -635,7 +634,7 @@ export default create({
     //监听 默认值更改
     watch(
       () => props.defaultValue,
-      val => {
+      (val) => {
         if (val) {
           resetRender();
         }

+ 1 - 0
src/packages/__VUE/cell/index.taro.vue

@@ -39,6 +39,7 @@ import { useRouter } from 'vue-router';
 import CellGroup from '../cellgroup/index.vue';
 const { componentName, create } = createComponent('cell');
 export default create({
+  children: [CellGroup],
   props: {
     title: { type: String, default: '' },
     subTitle: { type: String, default: '' },

+ 1 - 0
src/packages/__VUE/checkbox/index.taro.vue

@@ -6,6 +6,7 @@ import nutIcon from '../icon/index.taro.vue';
 import nutCheckboxGroup from '../checkboxgroup/index.vue';
 
 export default create({
+  children: [nutCheckboxGroup],
   components: {
     nutIcon,
     nutCheckboxGroup

+ 0 - 2
src/packages/__VUE/input/index.taro.vue

@@ -34,8 +34,6 @@
 <script lang="ts">
 import { ref, computed } from 'vue';
 import { createComponent } from '@/packages/utils/create';
-
-console.log('aaaa');
 function trimExtraChar(value: string, char: string, regExp: RegExp) {
   const index = value.indexOf(char);
 

+ 5 - 2
src/packages/__VUE/radio/index.taro.vue

@@ -1,12 +1,15 @@
 <script lang="ts">
 import { computed, h, inject } from 'vue';
+import nutIcon from '@/packages/__VUE/icon/index.taro.vue';
+import radiogroup from '@/packages/__VUE/radiogroup/index.vue';
 import { createComponent } from '../../utils/create';
-import nutIcon from '../icon/index.taro.vue';
-import radiogroup from '../radiogroup/index.vue';
 const { componentName, create } = createComponent('radio');
 
 export default create({
   children: [radiogroup],
+  components: {
+    'nut-radiogroup': radiogroup
+  },
   props: {
     disabled: {
       type: Boolean,

+ 1 - 5
src/packages/__VUE/steps/index.taro.vue

@@ -1,15 +1,11 @@
 <script lang="ts">
 import { provide, computed, reactive, h, ComponentInternalInstance } from 'vue';
 import Step from '../step/index.vue';
-import Icon from '../icon/index.taro.vue';
 import { createComponent } from '../../utils/create';
 const { create, componentName } = createComponent('steps');
 
 export default create({
-  components: {
-    [Step.name]: Step,
-    [Icon.name]: Icon
-  },
+  children: [Step],
   props: {
     direction: {
       type: String,

+ 3 - 10
src/packages/__VUE/swiper/index.taro.vue

@@ -1,6 +1,6 @@
 <template>
   <swiper
-    class="test-h"
+    class="nut-swiper"
     indicator-color="#999"
     indicator-active-color="#333"
     vertical
@@ -8,15 +8,6 @@
     indicator-dots
     autoplay
   >
-    <swiper-item>
-      <view class="demo-text-1">1</view>
-    </swiper-item>
-    <swiper-item>
-      <view class="demo-text-2">2</view>
-    </swiper-item>
-    <swiper-item>
-      <view class="demo-text-3">3</view>
-    </swiper-item>
   </swiper>
 </template>
 
@@ -27,6 +18,8 @@ import { useTouch } from './use-touch';
 import { useExpose } from '@/packages/utils/useExpose/index';
 const { create, componentName } = createComponent('swiper');
 // import swiperItem from '@/packages/__VUE/swiperitem/index.vue';
+// console.log(Taro)
+// console.log(Taro.createSelectorQuery)
 export default create({
   // children: [swiperItem],
   props: {},

+ 1 - 1
src/packages/__VUE/textarea/index.taro.vue

@@ -128,5 +128,5 @@ export default create({
 </script>
 
 <style lang="scss">
-@import './index.scss';
+@import 'index.scss';
 </style>

+ 3 - 3
src/shims-vue.d.ts

@@ -1,5 +1,5 @@
 declare module '*.vue' {
-  import type { DefineComponent } from 'vue'
-  const component: DefineComponent<{}, {}, any>
-  export default component
+  import type { DefineComponent } from 'vue';
+  const component: DefineComponent<{}, {}, any>;
+  export default component;
 }

+ 3 - 0
src/sites/mobile-taro/vue/src/pages/calendar/index.config.ts

@@ -0,0 +1,3 @@
+export default {
+  navigationBarTitleText: 'Calendar'
+};

+ 3 - 0
src/sites/mobile-taro/vue/src/pages/input/index.config.ts

@@ -0,0 +1,3 @@
+export default {
+  navigationBarTitleText: 'Input'
+};

+ 1 - 1
src/sites/mobile-taro/vue/src/pages/radio/index.vue

@@ -98,4 +98,4 @@ export default {
 };
 </script>
 
-<style lang="scss" scoped></style>
+<style lang="scss"></style>

+ 13 - 13
src/sites/mobile-taro/vue/src/pages/swiper/index.vue

@@ -2,25 +2,22 @@
   <div class="demo">
     <h2>基本用法</h2>
     <view class="demo-box">
-      <nut-swiper
-        :init-page="page"
-        :pagination-visible="true"
-        pagination-color="#426543"
-      >
-        <nut-swiper-item v-for="item in list" :key="item">
+      <nut-swiper>
+        1111
+        <!-- <nut-swiper-item v-for="item in list" :key="item">
           <img :src="item" alt="" />
-        </nut-swiper-item>
+        </nut-swiper-item> -->
       </nut-swiper>
     </view>
-    <h2>自定义大小</h2>
+    <!-- <h2>自定义大小</h2>
     <view class="demo-box">
       <nut-swiper :init-page="page2" :loop="false" width="300">
         <nut-swiper-item v-for="item in list" :key="item">
           <img :src="item" alt="" />
         </nut-swiper-item>
       </nut-swiper>
-    </view>
-    <h2>自定义指示器</h2>
+    </view> -->
+    <!-- <h2>自定义指示器</h2>
     <view class="demo-box">
       <nut-swiper :init-page="page3" :loop="true" @change="change">
         <nut-swiper-item v-for="item in list" :key="item">
@@ -30,8 +27,8 @@
           <div class="page"> {{ current }}/4 </div>
         </template>
       </nut-swiper>
-    </view>
-    <h2>垂直方向</h2>
+    </view> -->
+    <!-- <h2>垂直方向</h2>
     <view class="demo-box">
       <nut-swiper
         :init-page="page4"
@@ -46,12 +43,15 @@
           <img :src="item" alt="" />
         </nut-swiper-item>
       </nut-swiper>
-    </view>
+    </view> -->
   </div>
 </template>
 
 <script lang="ts">
 import { reactive, toRefs } from 'vue';
+import Taro from '@tarojs/taro';
+// console.log(Taro)
+// console.log(Taro.createSelectorQuery)
 export default {
   props: {},
   setup() {

+ 3 - 0
src/sites/mobile-taro/vue/src/pages/textarea/index.config.ts

@@ -0,0 +1,3 @@
+export default {
+  navigationBarTitleText: 'Textarea'
+};