Skip to content

Commit

Permalink
chore(card): optimize (#2438)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored Jul 19, 2023
1 parent 195a191 commit 51b69e8
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 428 deletions.
39 changes: 14 additions & 25 deletions packages/nutui-taro-demo/src/business/pages/card/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<view class="demo" :class="{ web: env === 'WEB' }">
<Header v-if="env === 'WEB'" />
<DocHeader />
<h2>基础用法</h2>
<nut-card
:img-url="state.imgUrl"
Expand Down Expand Up @@ -86,33 +86,22 @@
</view>
</template>

<script lang="ts">
<script setup lang="ts">
import { reactive } from 'vue';
import Taro from '@tarojs/taro';
import Header from '../../../components/header.vue';
import DocHeader from '../../../components/header.vue';
export default {
components: {
Header
},
setup() {
const env = Taro.getEnv();
const state = reactive({
imgUrl:
'//img10.360buyimg.com/n2/s240x240_jfs/t1/210890/22/4728/163829/6163a590Eb7c6f4b5/6390526d49791cb9.jpg!q70.jpg',
title: '活蟹】湖塘煙雨 阳澄湖大闸蟹公4.5两 母3.5两 4对8只 鲜活生鲜螃蟹现货水产礼盒海鲜水',
price: '388',
vipPrice: '378',
shopDesc: '自营',
delivery: '厂商配送',
shopName: '阳澄湖大闸蟹自营店>'
});
return {
state,
env
};
}
};
const env = Taro.getEnv();
const state = reactive({
imgUrl:
'//img10.360buyimg.com/n2/s240x240_jfs/t1/210890/22/4728/163829/6163a590Eb7c6f4b5/6390526d49791cb9.jpg!q70.jpg',
title: '活蟹】湖塘煙雨 阳澄湖大闸蟹公4.5两 母3.5两 4对8只 鲜活生鲜螃蟹现货水产礼盒海鲜水',
price: '388',
vipPrice: '378',
shopDesc: '自营',
delivery: '厂商配送',
shopName: '阳澄湖大闸蟹自营店>'
});
</script>

<style lang="scss">
Expand Down
32 changes: 12 additions & 20 deletions src/packages/__VUE/card/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
</view>
</template>

<script lang="ts">
import { computed, reactive, defineComponent } from 'vue';
<script setup lang="ts">
import { computed, reactive } from 'vue';
import { createComponent } from '@/packages/utils/create';
const { translate } = createComponent('card');
import { useTranslate } from '@/sites/assets/util/useTranslate';
Expand Down Expand Up @@ -108,24 +108,16 @@ const initTranslate = () =>
question: 'inquiry'
}
});
export default defineComponent({
setup() {
initTranslate();
const state = reactive({
imgUrl:
'//img10.360buyimg.com/n2/s240x240_jfs/t1/210890/22/4728/163829/6163a590Eb7c6f4b5/6390526d49791cb9.jpg!q70.jpg',
title: computed(() => translate('title')),
price: '388',
vipPrice: '378',
shopDesc: computed(() => translate('desc')),
delivery: computed(() => translate('delivery')),
shopName: computed(() => translate('shopName'))
});
return {
state,
translate
};
}
initTranslate();
const state = reactive({
imgUrl:
'//img10.360buyimg.com/n2/s240x240_jfs/t1/210890/22/4728/163829/6163a590Eb7c6f4b5/6390526d49791cb9.jpg!q70.jpg',
title: computed(() => translate('title')),
price: '388',
vipPrice: '378',
shopDesc: computed(() => translate('desc')),
delivery: computed(() => translate('delivery')),
shopName: computed(() => translate('shopName'))
});
</script>

Expand Down
178 changes: 75 additions & 103 deletions src/packages/__VUE/card/doc.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Used to display product pictures, prices and other information.

### Install

```javascript
```js
import { createApp } from 'vue';
import { Card } from '@nutui/nutui';

Expand All @@ -20,7 +20,7 @@ app.use(Card);

:::demo

```html
```vue
<template>
<nut-card
:img-url="state.imgUrl"
Expand All @@ -33,25 +33,18 @@ app.use(Card);
>
</nut-card>
</template>
<script>
import { reactive } from 'vue';
export default {
setup() {
const state = reactive({
imgUrl:
'//img10.360buyimg.com/n2/s240x240_jfs/t1/210890/22/4728/163829/6163a590Eb7c6f4b5/6390526d49791cb9.jpg!q70.jpg',
title: 'title',
price: '388',
vipPrice: '378',
shopDesc: 'desc',
delivery: 'delivery',
shopName: 'shopName>'
});
return {
state
};
}
};
<script setup>
import { reactive } from 'vue';
const state = reactive({
imgUrl:
'//img10.360buyimg.com/n2/s240x240_jfs/t1/210890/22/4728/163829/6163a590Eb7c6f4b5/6390526d49791cb9.jpg!q70.jpg',
title: 'title',
price: '388',
vipPrice: '378',
shopDesc: 'desc',
delivery: 'delivery',
shopName: 'shopName>'
});
</script>
```

Expand All @@ -61,7 +54,7 @@ app.use(Card);

:::demo

```html
```vue
<template>
<nut-card
:img-url="state.imgUrl"
Expand All @@ -81,43 +74,36 @@ app.use(Card);
</template>
</nut-card>
</template>
<script>
import { reactive } from 'vue';
export default {
setup() {
const state = reactive({
imgUrl:
'//img10.360buyimg.com/n2/s240x240_jfs/t1/210890/22/4728/163829/6163a590Eb7c6f4b5/6390526d49791cb9.jpg!q70.jpg',
title: 'title',
price: '388',
vipPrice: '378',
shopDesc: 'desc',
delivery: 'delivery',
shopName: 'shopName>'
});
return {
state
};
}
};
<script setup>
import { reactive } from 'vue';
const state = reactive({
imgUrl:
'//img10.360buyimg.com/n2/s240x240_jfs/t1/210890/22/4728/163829/6163a590Eb7c6f4b5/6390526d49791cb9.jpg!q70.jpg',
title: 'title',
price: '388',
vipPrice: '378',
shopDesc: 'desc',
delivery: 'delivery',
shopName: 'shopName>'
});
</script>
<style>
.search_prolist_attr {
margin: 3px 0 1px;
height: 15px;
overflow: hidden;
}
.search_prolist_attr > span {
float: left;
padding: 0 5px;
border-radius: 1px;
font-size: 10px;
height: 15px;
line-height: 15px;
color: #999;
background-color: #f2f2f7;
margin-right: 5px;
}
.search_prolist_attr {
margin: 3px 0 1px;
height: 15px;
overflow: hidden;
}
.search_prolist_attr > span {
float: left;
padding: 0 5px;
border-radius: 1px;
font-size: 10px;
height: 15px;
line-height: 15px;
color: #999;
background-color: #f2f2f7;
margin-right: 5px;
}
</style>
```

Expand All @@ -127,7 +113,7 @@ app.use(Card);

:::demo

```html
```vue
<template>
<nut-card
:img-url="state.imgUrl"
Expand All @@ -153,30 +139,23 @@ app.use(Card);
</template>
</nut-card>
</template>
<script>
import { reactive } from 'vue';
export default {
setup() {
const state = reactive({
imgUrl:
'//img10.360buyimg.com/n2/s240x240_jfs/t1/210890/22/4728/163829/6163a590Eb7c6f4b5/6390526d49791cb9.jpg!q70.jpg',
title: 'title',
shopName: 'shopName>'
});
return {
state
};
}
};
<script setup>
import { reactive } from 'vue';
const state = reactive({
imgUrl:
'//img10.360buyimg.com/n2/s240x240_jfs/t1/210890/22/4728/163829/6163a590Eb7c6f4b5/6390526d49791cb9.jpg!q70.jpg',
title: 'title',
shopName: 'shopName>'
});
</script>
<style>
.tag {
display: inline-block;
vertical-align: middle;
margin-right: 5px;
margin-left: 2px;
height: 14px;
}
.tag {
display: inline-block;
vertical-align: middle;
margin-right: 5px;
margin-left: 2px;
height: 14px;
}
</style>
```

Expand All @@ -186,7 +165,7 @@ app.use(Card);

:::demo

```html
```vue
<template>
<nut-card
:img-url="state.imgUrl"
Expand All @@ -202,30 +181,23 @@ app.use(Card);
</template>
</nut-card>
</template>
<script>
import { reactive } from 'vue';
export default {
setup() {
const state = reactive({
imgUrl:
'//img10.360buyimg.com/n2/s240x240_jfs/t1/210890/22/4728/163829/6163a590Eb7c6f4b5/6390526d49791cb9.jpg!q70.jpg',
title: 'title',
price: '388',
vipPrice: '378',
shopDesc: 'desc',
delivery: 'delivery',
shopName: 'shopName>'
});
return {
state
};
}
};
<script setup>
import { reactive } from 'vue';
const state = reactive({
imgUrl:
'//img10.360buyimg.com/n2/s240x240_jfs/t1/210890/22/4728/163829/6163a590Eb7c6f4b5/6390526d49791cb9.jpg!q70.jpg',
title: 'title',
price: '388',
vipPrice: '378',
shopDesc: 'desc',
delivery: 'delivery',
shopName: 'shopName>'
});
</script>
<style>
.customize {
font-size: 12px;
}
.customize {
font-size: 12px;
}
</style>
```

Expand Down
Loading

0 comments on commit 51b69e8

Please sign in to comment.