目录结构

 

├─ page
    ├─ index
    ├─ ├─ js
    ├─ ├─ ├─ index.js
    └─ index.vue

本着js和模板分离的思想去做项目的,js相关代码放到index.js里

js/index.js

 

import uniList from '@/components/uni-ui/uni-list/uni-list.vue';
import uniListItem from '@/components/uni-ui/uni-list-item/uni-list-item.vue';

export default {
  name: 'index',
  components: {
    uniList,
    uniListItem
  }
}

index.vue

 

<template>
  <view>
    <uni-list>
      <uni-list-item title="标题文字" show-arrow="false"></uni-list-item>
      <uni-list-item title="标题文字"></uni-list-item>
      <uni-list-item title="标题文字" show-badge="true" badge-text="12"></uni-list-item>
      <uni-list-item title="禁用状态" disabled="true" show-badge="true" badge-text="12"></uni-list-item>
    </uni-list>
  </view>
</template>

<script>
import index from './js/index.js';
export default index;
</script>

也没报错,也能打印出组件,但就是不显示,很奇怪,查了问了想了好久,最终尝试了不使用index.js,直接在index.vue里引入的方式,谁知还真的行,代码下如:

 

<template>
  <view>
    <uni-list>
      <uni-list-item title="标题文字" show-arrow="false"></uni-list-item>
      <uni-list-item title="标题文字"></uni-list-item>
      <uni-list-item title="标题文字" show-badge="true" badge-text="12"></uni-list-item>
      <uni-list-item title="禁用状态" disabled="true" show-badge="true" badge-text="12"></uni-list-item>
    </uni-list>
  </view>
</template>

<script>
import uniTag from "@/components/uni-ui/uni-tag/uni-tag.vue";
import uniList from '@/components/uni-ui/uni-list/uni-list.vue';
import uniListItem from '@/components/uni-ui/uni-list-item/uni-list-item.vue';
export default {
  name: 'member_center',
  components: {
    uniTag,
    uniList,
    uniListItem
  }
}
</script>

一个让我头疼了很久的问题,就这样解决了,懵了,可能是uniapp或小程序做的限定吧

Logo

前往低代码交流专区

更多推荐