我一直在将/**
* This is our callback
* function that embeds our phrase in a WP_REST_Response
*/
function addProductFromCRM($data) {
//$name = $data['name'];
// rest_ensure_response() wraps the data we want to return into a WP_REST_Response, and ensures it will be properly returned.
return rest_ensure_response($data);
}
/**
* This function is where we register our routes for our example endpoint.
*/
function wp_register_crm_routes() {
// register_rest_route() handles more arguments but we are going to stick to the basics for now.
register_rest_route('crm/v1', '/addproduct/', array(
// By using this constant we ensure that when the WP_REST_Server changes our readable endpoints will work as intended.
'methods' => 'POST',
// Here we register our callback. The callback is fired when this endpoint is matched by the WP_REST_Server class.
'callback' => 'addProductFromCRM',
));
}
add_action('rest_api_init', 'wp_register_crm_routes');
样式表添加到我的Rails 4.2应用程序的React-Rails / Webpack组件中:
react-datepicker
具有在所需组件中调用的必需库:
<head>
...
<%= csrf_meta_tags %>
<%= action_cable_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= stylesheet_pack_tag 'application' %>
...
<head/>
<body
<%= javascript_pack_tag 'application' %>
<div id="footer" class="site-footer no-print">
© 2019
</div>
在检查github仓库中日期选择器(https://github.com/Hacker0x01/react-datepicker/issues/879)的问题时,我尝试了一些其他与该问题相关的选项:
import React, { useState, useEffect } from 'react'
import DatePicker from "react-datepicker"
import "react-datepicker/dist/react-datepicker.min.css"
虽然都没有抛出错误,但是没有访问任何样式。将文件更改为类似import "react-datepicker/dist/react-datepicker.css"
import 'react-datepicker/dist/react-datepicker-cssmodules.min.css'
did 的操作会引发错误,因此可以找到并导入它们,但是chrome inspector无法选择样式。