我想使用 WP REST API 从自定义帖子类型获取数据。
我的自定义帖子类型是“结果”,我已尝试使用此参数。
http://ejobbox.com/wp-json/wp/v2/result/?
http://ejobbox.com/wp-json/wp/v2/result/?per_page=10
Run Code Online (Sandbox Code Playgroud)
并且还与
http://ejobbox.com/wp-json/wp/v2/posts/?post_type=result
Run Code Online (Sandbox Code Playgroud)
但我无法使用自定义帖子类型获取数据。
我还将其添加到我的自定义帖子类型中
'show_in_rest'=> true,
'rest_base' => 'result',
'rest_controller_class' => 'WP_REST_Posts_Controller',
Run Code Online (Sandbox Code Playgroud)
我仍然没有得到任何结果。
请问,您能告诉我我在这里做错了什么吗?我该怎么做才能从自定义帖子类型中获取数据?请给我一个建议。
我的 Function.php (自定义帖子类型)代码在这里:
function codexres_custom_init() {
$args = array(
'public' => true,
'label' => 'Result'
);
register_post_type( 'result', $args );
}
add_action( 'init', 'codexres_custom_init' );
function codex_result_init() {
$labels = array(
'name' => _x( 'Result', 'post type general name', 'your-plugin-textdomain' ),
'singular_name' => _x( 'Result', 'post type singular name', 'your-plugin-textdomain' ),
'menu_name' => _x( 'Result', 'admin …Run Code Online (Sandbox Code Playgroud) 我使用react-native-google-places-autocomplete包进行 google place 自动完成文本输入。但是在这里我每次点击地址后都会收到警告。
警告::
VirtualizedLists 不应该嵌套在具有相同方向的普通 ScrollViews 中 - 使用另一个 VirtualizedList-backed 容器代替。
我应该使用的另一个 VirtualizedList 支持的容器是什么,为什么现在建议不要那样使用?
我为此创建了一个自定义组件,下面我在 GooglePlacesInput 组件的渲染中添加代码:
class GooglePlacesInput extends PureComponent {
//..... other function
// render function
render() {
const { placeholder, minSearchLen, address, name, enablePoweredByContainer, currentLocation, onChangeText } = this.props;
return (
<GooglePlacesAutocomplete
placeholder={placeholder}
name={name}
minLength={minSearchLen}
autoFocus={false}
returnKeyType={'search'} // Can be left out for default return key https://facebook.github.io/react-native/docs/textinput.html#returnkeytype
keyboardAppearance={'light'} // Can be left out for default keyboardAppearance https://facebook.github.io/react-native/docs/textinput.html#keyboardappearance
listViewDisplayed="false" // true/false/undefined
fetchDetails={true}
getDefaultValue={() => …Run Code Online (Sandbox Code Playgroud) 我正在构建一个 React Native 应用程序并尝试使用 navigator.geolocation 获取我当前的地理编码它向我显示位置请求超时错误。基本上我正在构建一个跟踪应用程序,我需要配置确切的位置纬度经度。要开始跟踪,有一个按钮,单击此跟踪将开始,它应该是跟踪的初始点。我正在使用默认的 react native geolocation API,链接https://facebook.github.io/react-native/docs/geolocation 函数来获取我当前的位置::
getLocation() {
navigator.geolocation.getCurrentPosition(response => {
console.log(response);
if (response && response.coords) {
this.saveLogs(response.coords);
}
},
(error) => {
this.onGeolocationErrorOccurCallback(error);
},
GeolocationOptions
)
}
Run Code Online (Sandbox Code Playgroud)
它向我显示了一个错误::
{"TIMEOUT":3,"POSITION_UNAVAILABLE":2,"PERMISSION_DENIED":1,"message":"位置请求超时","code":3}
我已经为 Android 设备添加了权限,并且还通过将 enableHighAccuracy 值设置为 false 来进行检查。但这对我不起作用。我需要将 enableHighAccuracy 设置为 true,因为我想要精确的地理编码来跟踪某人。请建议为什么在这里发生位置请求超时?
描述::
我正在开发反应本机应用程序。我的应用程序有登录和注册页面。注册后,我将向用户发送一封电子邮件以验证帐户。用户将获得一个验证帐户的链接,单击该链接后,我将用户重定向到我正在验证他的网址。现在,如果用户使用手机进行验证,我想将用户重定向到“我的应用程序”验证屏幕内。
使用 React Native 是如何完成的?
重定向到电子邮件验证链接后,如何将用户移动到“我的应用程序”内?
我正在使用深层链接概念来重定向应用程序内的用户。我遵循的步骤如下:
对于安卓::
我已将其添加到 AndroidManifest.xml 文件中::
<activity
android:name=".MainActivity"
android:launchMode="singleTask"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
Run Code Online (Sandbox Code Playgroud)
并添加数据如下:
<intent-filter android:label="filter_react_native">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="myurl"
android:pathPrefix="/verify-email"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
之后,我在我的 app.js 文件中添加了以下代码:
componentDidMount() {
console.log('hi');
Linking.addEventListener('url', this._handleOpenURL);
}
componentWillUnmount() {
Linking.removeEventListener('url', this._handleOpenURL);
}
_handleOpenURL(event) {
console.log('url', event.url);
Run Code Online (Sandbox Code Playgroud)
当我点击此网址“ http://myurl/verify-email/demo ”时,我没有在控制台中获取任何数据,也没有打开我的应用程序。我正在调试模式下运行我的应用程序。
Firebase 动态链接也可以实现此目的,但有人可以告诉我其中哪种方法最好?
对于“Firebase Dynamic Link”,我应该在哪里添加代码来处理整个应用程序的动态链接?
我已经集成了 React Native 导航包。我想在我的 topBar rightButton 上添加带有动态值的徽章。包的 Github 链接::https : //github.com/wix/react-native-navigation
我想要这样的输出。您可以查看此屏幕截图::
问题::
如果我在通知图标上添加计数值,那么当我尝试单击按钮时不会发生任何事件。单击此按钮后,我想打开通知屏幕。
代码:
static options({ menuIcon }) {
return {
topBar: {
title: {
fontFamily: font,
fontSize: fontSize.heading,
color: colors.white,
alignment: 'center',
text: strings.dashboard
},
alignment: 'center',
elevation: 0,
noBorder: true,
background: {
color: colors.dark
},
leftButtons: [
{
id: 'openSideMenu',
icon: menuIcon ? menuIcon : APIURLServiceSingleton.getInstance()._menuIcon
}
],
rightButtons: [
{
id: 'notificationButton',
component: {
name: 'component.notificationButton'
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的自定义组件的代码::
<TouchableOpacity
onPress={() …Run Code Online (Sandbox Code Playgroud) 我正在使用 react native 创建一个预订应用程序,我必须在其中显示多个列表。有人能告诉我哪个最好用,原生 FlatList 还是 Flipkart recyclerlistview?
React Native FlatList:: https://facebook.github.io/react-native/docs/flatlist
Flipkart recyclerlistview :: https://github.com/Flipkart/recyclerlistview
我正在使用Ubuntu OS 16.04。我使用以下命令启动mongodb ::
sudo service mongod start然后
mongo
它为我生成了此错误::
MongoDB shell version v4.0.1
connecting to: mongodb://127.0.0.1:27017
2018-09-27T16:50:41.345+0530 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed
Run Code Online (Sandbox Code Playgroud)
现在,我无法启动mongodb。如何解决此错误以及这些错误的原因是什么。我针对此问题尝试了所有解决方案,但未找到任何解决方案。
我想将 node 升级到 12.10.0 并将 npm 升级到 6.11.3,目前我正在使用 macOS Mojave 版本 10.14.5
我正在使用这些命令将节点版本升级到 12.10.0::
sudo npm cache clean -f (强制)清除你的 npm 缓存sudo npm install -g n 安装 n(这可能需要一段时间)sudo n 12.10.0 升级到特定版本运行最后一个命令后,它给了我一个输出:
installing : node-v12.10.0
mkdir : /usr/local/n/versions/node/12.10.0
fetch : https://nodejs.org/dist/v12.10.0/node-v12.10.0-darwin-x64.tar.gz
installed : v12.10.0 to /usr/local/bin/node
active : v10.16.3 at /usr/local/opt/node@10/bin/node
Run Code Online (Sandbox Code Playgroud)
当我检查节点版本时,node -v它仍然显示旧版本10.16.3
我试图添加节点路径,但它仍然给我相同的输出。我已经使用了命令sudo nano /etc/path,然后添加/usr/local/bin/node了它的路径。
请建议我如何将 node 升级到 12.10.0 并将 npm 升级到 6.11.3 版本?
我正在研究 golang 项目,最近我阅读了有关 docker 的文章,并尝试在我的应用程序中使用 docker。我正在使用 mongoDB 作为数据库。现在的问题是,我正在创建 Dockerfile 来安装所有软件包并编译和运行 go 项目。我在本地运行 mongo 数据,如果我在没有 docker 的情况下运行 go 程序,它会给我输出,但是如果我在同一个项目中使用 docker(只是安装依赖项并运行项目),它会成功编译但不提供任何输出,有错误::
CreateSession: no reachable servers
Run Code Online (Sandbox Code Playgroud)
我的 Dockerfile::
# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang
WORKDIR $GOPATH/src/myapp
# Copy the local package files to the container's workspace.
ADD . /go/src/myapp
#Install dependencies
RUN go get ./...
# Build the installation command inside the container.
RUN go install …Run Code Online (Sandbox Code Playgroud) 这是错误和控制台错误的图像...
我的代码似乎是正确的,并且导入的路径也很好,我不明白为什么会收到此错误。
App.js
import React, { Component } from 'react';
import {BrowserRouter, Route, Switch} from 'react-router-dom'
import Navbar from './components/layout/Navbar'
import Dashboard from './components/dashboard/Dashboard'
class App extends Component {
render() {
return (
<BrowserRouter>
<div className="App">
<Navbar/>
<Switch>
<Route path="/" component={Dashboard}/>
</Switch>
</div>
</BrowserRouter>
);
}
}
export default App;
Run Code Online (Sandbox Code Playgroud)
Dashboard.js
import React, {Component} from 'react'
import Notifications from './Notifications'
import ProjectList from '../projects/ProjectList'
class Dashboard extends Component {
render() {
return(
<div>
<div className="dashboard container">
<div className="row">
<div className="col …Run Code Online (Sandbox Code Playgroud) 我在本机应用程序上集成了 firebase Crashlytics。我想在开发模式下禁用崩溃日志。如何在调试模式下为 Android 和 Ios 应用程序禁用崩溃日志。要创建崩溃日志,我遵循了 react native firebase 文档,请查看此官方链接 :: https://rnfirebase.io/docs/v5.xx/crashlytics/android
我正在使用 react-native-firebase 版本 5.2.2
我想在不更改版本的情况下禁用调试模式下的日志。我想添加代码来禁用 Android 和 Ios 的崩溃日志。请建议如何做到这一点。
我正在尝试使用 golang mgo 执行查询,以有效地从连接中获取相似的值。
我的结构是这样的:
result: [
{
"_id" : 1,
"booking_id" : 96,
"provider_id" : 20,
"time" : NumberLong(1541158790),
"arrival_time" : NumberLong(1541158863)
},
{
"_id" : 3,
"booking_id" : 96,
"provider_id" : 20,
"time" : NumberLong(1541158908),
},
{
"_id" : 4,
"booking_id" : 95,
"provider_id" : 20,
"type" : "abc",
"time" : NumberLong(1541163544),
"location" : {
"lat" : 30.711858,
"lng" : 76.729649
},
},
{
"_id" : 8,
"booking_id" : 95,
"provider_id" : 20,
"type" : "aaa",
}
] …Run Code Online (Sandbox Code Playgroud) react-native ×6
mongodb ×3
android ×1
crashlytics ×1
deep-linking ×1
docker ×1
firebase ×1
geolocation ×1
go ×1
ios ×1
macos ×1
mgo ×1
node.js ×1
react-router ×1
reactjs ×1
rest ×1
upgrade ×1
wordpress ×1