first commit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<view @click="onClick">
|
||||
<slot></slot>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { chooseFile } from '@/uni_modules/lime-choose-file'
|
||||
export default {
|
||||
props: {
|
||||
disabled: Boolean
|
||||
},
|
||||
emits: ['success', 'fail'],
|
||||
data() {
|
||||
return {
|
||||
images: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClick() {
|
||||
if(this.disabled) return
|
||||
chooseFile({
|
||||
success:(res)=>{
|
||||
this.$emit('success', res)
|
||||
},
|
||||
fail(err){
|
||||
this.$emit('fail', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,103 @@
|
||||
<template>
|
||||
<view class="demo-block">
|
||||
<text class="demo-block__title-text ultra">ChooseFile 文件选择</text>
|
||||
<text class="demo-block__desc-text">打开系统文件管理器选择文件。</text>
|
||||
<view class="demo-block__body">
|
||||
<view class="demo-block card">
|
||||
<text class="demo-block__title-text large">基础使用</text>
|
||||
<view class="demo-block__body row">
|
||||
<button @click="onClick">选择图片</button>
|
||||
<image v-for="(item, index) in images" :key="index" :src="item"></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { chooseFile, ChooseFileOption } from '@/uni_modules/lime-choose-file'
|
||||
|
||||
const images = ref<string[]>([])
|
||||
const onClick = () => {
|
||||
chooseFile({
|
||||
// filename: 'xxx',
|
||||
type: 'image',
|
||||
success(res) {
|
||||
images.value = res.tempFiles.map((item) : string => item.path)
|
||||
console.log('res', res.tempFiles)
|
||||
console.log('reserrMsg', res)
|
||||
},
|
||||
fail(err) {
|
||||
console.log('err', err)
|
||||
}
|
||||
} as ChooseFileOption)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.row {
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-bottom: 20rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.demo-block {
|
||||
margin: 32px 10px 0;
|
||||
|
||||
// overflow: visible;
|
||||
&.card {
|
||||
background-color: white;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx !important;
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin: 0;
|
||||
margin-top: 8px;
|
||||
|
||||
&-text {
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
line-height: 16px;
|
||||
display: flex;
|
||||
|
||||
&.large {
|
||||
color: rgba(0, 0, 0, 0.9);
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
line-height: 26px;
|
||||
}
|
||||
|
||||
&.ultra {
|
||||
color: rgba(0, 0, 0, 0.9);
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
line-height: 32px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__desc-text {
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
margin: 8px 16px 0 0;
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
&__body {
|
||||
margin: 16px 0;
|
||||
overflow: visible;
|
||||
|
||||
.demo-block {
|
||||
// margin-top: 0px;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,36 @@
|
||||
<template>
|
||||
<view>
|
||||
<button @click="onClick">选图</button>
|
||||
<image v-for="(item, index) in images" :key="index" :src="item"></image>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { chooseFile } from '@/uni_modules/lime-choose-file'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
images: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClick() {
|
||||
chooseFile({
|
||||
type: 'image',
|
||||
success:(res)=>{
|
||||
this.images = res.tempFiles.map((item) => item.path)
|
||||
console.log('res', res.tempFiles)
|
||||
},
|
||||
fail(err){
|
||||
console.log('err', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user