Skip to content

Image doesn't preview after taking photo with vuejs #127

@natatatata

Description

@natatatata

How will you show the image after it was taken? I'm using ### nativescript-vue with 'nativescript-vue-template' as the template and this is the code I'm using. Thanks!

const Vue = require('nativescript-vue');
const camera = require('nativescript-camera');
const imageModule = require('tns-core-modules/ui/image');

new Vue({
  data() {
    return{
       image: ""
    };
  },
  methods: {    
    openCamera()
    {
      var options = { cameraFacing: 'front'};
      camera.requestPermissions();
      if(camera.isAvailable())
      {
        camera.takePicture(options)
          .then(function(imageAsset) {
            console.log("src: " + imageAsset.android);
            var image = new imageModule.Image();
            image.src = imageAsset.android;
          })
          .catch(function (err) {
            console.log("Error -> " + err.message);
          });
      } 
    }
  },
  template:
   '
    <page>
      <action-bar title="Test App"></action-bar>
      <stack-layout>
        <Button @tap="openCamera()" text="Open Camera"></button>
        <Image :src="image" />
        </stack-layout>
    </page>
    '
}).$start();

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions