NativeScript / NativeScript/plugins
imagepicker with NativeScript Vue is not working
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- TypeScript
- Estrelas
- 206
- Forks
- 123
- Merge médio
- 2d 1h
- PRs com merge (30d)
- 1
Descrição
Hello,
I'm writing an application in nativescript vue where I need to pick an image on iOS Photo Library.
For that I wanted to use the imagepicker plugin.
Authorization is working and I can select the pictures, but unfortunately as result I got that the uri is undefined.
Here after my code :
<template>
<Page @loaded="onPageLoaded">
<ActionBar title="Select Image" />
<StackLayout>
<Button text="Select Image" @tap="onSelectImageTap" />
<Image v-if="selectedImage" :src="selectedImage" stretch="aspectFill" />
</StackLayout>
</Page>
</template>
<script>
import * as ImagePicker from 'nativescript-imagepicker';
export default {
data() {
return {
selectedImage: null,
imagePicker: null // Initialize imagePicker property
};
},
methods: {
onPageLoaded() {
this.imagePicker = ImagePicker.create({
mode: 'single' // or 'multiple'
});
},
async onSelectImageTap() {
try {
if (!this.imagePicker) {
console.error('ImagePicker is not initialized.');
return;
}
await this.imagePicker.authorize();
const selection = await this.imagePicker.present();
console.log('Selection:', selection.map(item => ({ uri: item.uri })));
if (selection && selection.length > 0 && selection[0].uri) {
this.selectedImage = selection[0].uri;
} else {
console.error('No image selected or URI is undefined.');
}
} catch (error) {
console.error('Error selecting image:', error);
}
}
}
};
</script>
It seems that the same issue is happing also on the demo available under : https://www.npmjs.com/package/@nativescript/imagepicker#demo -> https://stackblitz.com/edit/nativescript-vue3-beta-krjk9k?file=app%2Fcomponents%2FHome.vue,app%2Fapp.css
Can you support me on this issue?
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece executando a demonstração vinculada do StackBlitz no iOS e inspecione app/components/Home.vue; app/app.css está disponível como parte da demonstração. Reproduza a seleção de imagem e compare o objeto de seleção retornado com a undefined uri registrada na issue. Está concluído quando a imagem selecionada expõe uma URI utilizável no exemplo do NativeScript Vue.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- ios, typescript
- Domínio
- mobile-dev
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Precisa de esclarecimento
- Facilidade para iniciantes
- 25/100