小编Esa*_*med的帖子

如何获取被轻击的列表项的上下文以在Nativescript的另一页中显示详细信息

我正在尝试创建一个列表视图,以显示硬编码数组列表中的数据及其工作情况,但是我需要使用户能够单击任何项​​目以在另一页中显示该项目的详细信息,我该怎么做?我试图为细节创建另一个数组,并使bindingContext及其工作正常,但在转换为细节页面时没有数据显示,如您在此处看到的

那就是我的代码:

main-view-model.js:

var Observable = require("data/observable").Observable;

function RegisterViewModel() {
    var viewModel = new Observable();
    viewModel.shows = [
        {name:"Reg1"},
        {name:"Reg2"},
        {name:"Reg3"},
        {name:"Reg4"},
        {name:"Reg5"},


    ];

    return viewModel;

}

exports.RegisterViewModel = RegisterViewModel;
Run Code Online (Sandbox Code Playgroud)

main-page.js:

var RegisterViewModel = require("./main-view-model").RegisterViewModel;
var frameModule = require('ui/frame'); 


var viewModel = new RegisterViewModel();
function RegisterViewModel(args) {
var page = args.object;
page.bindingContext = RegisterViewModel();
}

exports.getInfo = function (args) {
     var navigationEntry = { 
     moduleName: "RegisterDetails",
     context: {info:args.view.bindingContext}
      }
      frameModule.topmost().navigate(navigationEntry);
    }

exports.loaded = function(args){
    args.object.bindingContext = viewModel;
}


exports.RegisterViewModel = …
Run Code Online (Sandbox Code Playgroud)

javascript data-binding android listview nativescript

2
推荐指数
1
解决办法
792
查看次数

如何在 React Native 中通过上传图片获取数据到 php 服务器

我有一个 react native 项目,它从文本输入接收姓名、电子邮件、电话号码,然后将这些数据插入到 php 服务器 throw fetch api 并且它工作正常,但我需要让用户能够上传图像,当点击保存按钮时,所有数据(姓名,电子邮件,电话号码,照片)保存到php服务器抛出api,现在我使用“react-native-image-picker”并且工作正常但我不知道如何使用表单数据上传带有数据抛出api的图像.

这是反应本机代码:

 import React, { Component } from 'react';
import {View,Text,StyleSheet,TextInput,TouchableOpacity,Image} from 'react-native';
import ViewDataUsers from './ViewDataUsers';

import ImagePicker from 'react-native-image-picker';

const options={
    title:'select a photo',
    takePhotoButtonTitle:'Take a Photo',
    chooseFrmoLibraryButtonTitle:'Choose from Gallery',
    quality:1
};




class InputUsers extends Component{

//constructor have a state that conatains the properties that will recieve the values from Text Inputes 
    constructor(props){
       super(props) 
        this.state = {
            TextInputName:'',
            TextInputEmail:'',
            TextInputPhoneNumber:'',
            iamgeSource: null,
        }
    }

    selectPhoto(){
        ImagePicker.showImagePicker(options, (response) => { …
Run Code Online (Sandbox Code Playgroud)

php api form-data react-native react-native-fetch-blob

2
推荐指数
1
解决办法
9861
查看次数