I'm using Nativescript-vue. I'm trying to put some logic in my app, that doesn't show any html or anything, its just a library that does calculations. I can't figure out how to just use it, i keep getting error messages.
Here is what I've tried.
rifle.js
export function Rifle () { // no function name
this.firstName = "hi";
}
also tried this and others:
const observableModule = require("tns-core-modules/data/observable");
function Rifle () { // no function name
const myRifle = observableModule.fromObject({
firstName:"hello"
})
return myRifle;
}
module.exports = Rifle;
then in my App.js file, i import it.
import {Rifle} from "./ballisticlibrary/rifle";
I've also tried to use Require instead.
I then try to use it in a vue method, invoked on button tap.
GetRifle()
{
// return "hi";
this.msg= this.Rifle.firstName;
}
Keeps throwing an error of :
Cannot read property 'firstName' of undefined"
System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onClick failed
System.err: TypeError: Cannot read property 'firstName' of undefined