不完全確定如何放置這個,但Meteor.call和.methods在移動設備上構建應用程序時無法正常工作在iOS上,雖然我還沒有在Android上嘗試過。在我之前的項目中,這不會發生。我試圖與其他應用程序進行比較,實際上,我重新使用了其他應用程序,但它不起作用。此外,在網頁和iOS模擬器上的一切工作都很完美。有人請幫忙。Meteor.call和Meteor.methods不適用於移動設備(iOS),但完全適用於網絡和iOS模擬器
進口/啓動/服務器/ methods.js
import { HTTP } from 'meteor/http';
import { Meteor } from 'meteor/meteor';
Meteor.methods({
methodTrial: function(data) {
console.log("Called methodTrial");
return false;
}
});
進口/啓動/ UI /網頁/ home.js
import './home.html';
import { Meteor } from 'meteor/meteor';
Template.payment.events({
"click #test-method": (event) => {
var data = {
name : "Hello World"
};
Meteor.call('methodTrial', data, (error, result) => {
console.log("Called 'methodTrial'");
}
}
});
進口/啓動/服務器/ index.js
import './methods.js';
server/main.js
import { Meteor } from 'meteor/meteor';
import '/imports/startup/server';
你是否在設備上運行調試? (即'meteor run ios-device')如果是這樣,你是否檢查過你的設備可以通過WiFi連接到你的本地服務器? – ghybs
@ghybs嗯我不確定在「調試」,但是我通過ios設備運行它。我確信兩臺設備都連接在同一個網絡上並連接到正確的IP地址。如果它根本不工作,它不會在模擬器上工作。 – zangetsu
模擬器不必通過WiFi,而您的設備必須通過。可能值得確認設備可以通過['Meteor.status()'](http://docs.meteor.com/api/connections.html#Meteor-status)連接到你的服務器 – ghybs