我目前正在学习react-native,我正在开发一个使用地理定位来查找和更新我当前位置的应用程序,我正在遵循该教程,在教程中我必须使用带有超时和maximumAge选项的属性。
navigator.geolocation.getCurrentPosition((pozitie)=>{
var lat = parseFloat(position.coords.latitude)
var long = parseFloat(position.coords.longitude)
// create an object with the current position taken from the geolocation chip
var initialLocation = {
latitude = lat,
longitude = long,
// Delta is the viewing angle on the location of the user
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA
}
// Now we are seting initial position to the initial location
this.setState({initialPositionOnTheMap: initialLocation})
// we set the marker to the initial location and then the display …Run Code Online (Sandbox Code Playgroud) 我正在使用笑话和酶为 React Native 应用程序编写单元测试。当我尝试运行测试用例时,出现以下错误:
\n\n\n\n\n\xe2\x97\x8f 测试套件运行失败
\n\n类型错误:无法读取未定义的属性“SHORT”
\n\n在对象。(node_modules/react-native-simple-toast/index.js:7:23)\n 在对象处。(src/client/components/Catalogue/events.js:10:29)\n 在对象处。(测试/events-test.js:5:13)\n 在 Generator.next ()\n 在 new Promise ()\n 在 Generator.next ()\n 在
\n
该错误是由于从react-native-simple-toast导入Toast造成的。如果没有这个导入,测试运行正常,但我的组件中需要react-native-simple-toast,因此无法删除它。我以某种方式需要测试在我的组件中使用react-native-simple-toast运行:
\n\nimport React, { Component } from 'react'\nimport { Platform, ActivityIndicator, Linking, Dimensions, View, Text, \nTouchableOpacity, TextInput, StyleSheet, Keyboard, Image, \nKeyboardAvoidingView } from 'react-native'\nimport { Container, Header, Card, CardItem, Content, Left, Right, Body, \nTitle, Icon, Button } from 'native-base';\nimport IconIOSback from 'react-native-vector-icons/Ionicons';\nimport IconMenu from 'react-native-vector-icons/MaterialIcons';\nimport axios from 'axios';\nimport SERVER_URL from …Run Code Online (Sandbox Code Playgroud) 我已经尝试过: #448
\n\n环境
\n\nSystem:\nOS: macOS 10.15\nCPU: (4) x64 Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz\nMemory: 30.63 MB / 4.00 GB\nShell: 3.2.57 - /bin/sh\nBinaries:\nNode: 10.15.3 - /usr/local/bin/node\nYarn: 1.19.2 - /usr/local/bin/yarn\nnpm: 6.13.1 - /usr/local/bin/npm\nSDKs:\niOS SDK:\nPlatforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1\nIDEs:\nXcode: 11.2.1/11B500 - /usr/bin/xcodebuild\nnpmPackages:\nreact: 16.9.0 => 16.9.0\nreact-native: 0.61.5 => 0.61.5\nRun Code Online (Sandbox Code Playgroud)\n\n描述
\n\n\n\n\xe2\x9e\x9c ios git:(master) \xe2\x9c\x97 pod install --verbose\n/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /Users/jack/Desktop/root in PATH, mode 040777\n\n[!] Invalid Podfile file: 767: unexpected token …Run Code Online (Sandbox Code Playgroud) 我正在为我的应用程序实施应用程序WebView。我必须打开一些信息页面,并且必须根据 web 视图中任何特定位置(包含不同类型的数据)的点击来获取一些数据。但在 iOS 中,在加载任何 URL 时onShouldStartLoadWithRequest会自动调用,这会导致在 HTML 内容中打开不同的 URL。但它在 Android 中按预期工作。
<WebView
originWhitelist={["*"]}
style={style}
source={source}
showsVerticalScrollIndicator={showsVerticalScrollIndicator}
startInLoadingState={startInLoadingState}
javaScriptEnabled={true}
onShouldStartLoadWithRequest={request => {
return onLoadWebViewOnClick(request)
}}
/>
Run Code Online (Sandbox Code Playgroud)
在这个handleUrlNavigation中会处理任何点击动作的请求,但是它每次都会自动调用。我该如何处理这个问题?
我\xe2\x80\x99m 尝试使用该npm run ios命令运行我的React Native 项目。\n但由于某些问题,它一次又一次无法运行。\n它打印出的错误消息如下所示。
GetRest@0.0.1 ios /Users/user/Documents/w_space/bo.git/getrest\n\nreact-native run-ios\n\nerror Could not find the following native modules: RNSVG, RNSVG. Did you forget to run "pod install" ?\n\ninfo Found Xcode workspace "GetRest.xcworkspace"\n\ninfo Building (using "xcodebuild -workspace GetRest.xcworkspace -configuration Debug -scheme GetRest -destination id=81866BE1-BBBB-4A67-990A-3B0B8A613075")\n\n.............\n\nerror Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening GetRest.xcworkspace. Run CLI with --verbose flag …Run Code Online (Sandbox Code Playgroud) 我在原生项目iOS应用程序上有3个按钮.如何将类激活设置为单击按钮并从其他人中删除此类?就像我在jquery上使用的addClass/removeClass一样?
我正在尝试创建一个界面,其中卡片一次一个地呈现给用户.用户可以以分页的方式向左和向右滚动.我还想查看当前卡片左侧和右侧的少量卡片,作为暗示还有更多内容可供查看.一个非常粗略的例子是:
目前的代码是:
<ScrollView
style={{width: Dimensions.get('window').width, height: 300}}
horizontal={true}
pagingEnabled={true}
showsHorizontalScrollIndicator={false}
alwaysBounceHorizontal={false}
automaticallyAdjustContentInsets={false}>
<View style={{width: 200, height: 300}}></View>
<View style={{width: 200, height: 300}}></View>
<View style={{width: 200, height: 300}}></View>
</ScrollView>
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用了材料下拉列表
<Dropdown
baseColor='white'
itemColor='white'
label='Select Cluster'
/>
Run Code Online (Sandbox Code Playgroud)
我像这样获取JSON对象,它工作正常.
fetch('url', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
username : "admin"
})
}).then((response) => response.json())
.then((responseJson) => {
var count = Object.keys(responseJson.message.Obj).length;
for(var i=0;i<count;i++){
console.log(responseJson.message.Obj[i].name) // I need to add
//these names to dropdown
}
})
.catch((error) => {
console.error(error);
});
Run Code Online (Sandbox Code Playgroud)
现在我需要将
responseJson.message.Obj[i].name值添加到我的下拉列表中.
javascript react-native react-native-android react-native-ios
react-native ×10
react-native-ios ×10
javascript ×3
ios ×2
cocoapods ×1
enzyme ×1
geolocation ×1
iphone-x ×1
jestjs ×1
unit-testing ×1
xcode ×1