小编Mah*_*esh的帖子

Axios - 如何阅读JSON响应?

Axios 0.17.1

.then(function (response) {
                console.log(response);
                //console.log(response.status);
                //It is an error -> SyntaxError: Unexpected token u in JSON at position 0 
                console.log(JSON.parse(response.data.error));
                console.log(response.data.error); //undefined.
Run Code Online (Sandbox Code Playgroud)

console.log的响应是

{data:"{"error":"名称必须输入多个...NULL↵
["isPipe":protected] =>↵NULL↵}↵}↵",状态:203,statusText:"非权威信息",header:{...},config:{...},...} config:{adapter:ƒ,transformRequest:{...},transformResponse:{...},timeout:0,xsrfCookieName:"XSRF-TOKEN",...}数据: "{"错误":".名称必须与多于一个的字符来输入"}对象(超薄\ HTTP \响应)#32(5){↵["状态":保护] =>↵INT(200)↵ ["reasonPhrase":protected] =>↵string(0)""↵["protocolVersion":protected] =>↵string(3)"1.1"↵["headers":protected] =>↵对象(Slim\Http \集管)#33(1){↵
[ "数据":保护] =>↵阵列(1){↵[ "内容类型"] =>↵
阵列(2){↵[ "值"] =>↵ array(1){↵[0] =>↵string
(24)"text/html; charset = UTF-8"↵}↵
["originalKey"] =>↵字符串(12)"Content-Type"↵}↵ }↵}↵["body":protected] =>↵对象(Slim\Http\Body)#31(7){↵
["stream":protected] =>↵资源(59)类型(流)↵
[ "元":保护 ED] =>↵NULL↵[ "可读的":保护] =>↵NULL↵
[ "可写":保护] =>↵NULL↵[ "可搜索":保护] =>↵
NULL↵[ "大小":保护] =>↵NULL↵["isPipe":protected] =>
↵NULL↵}↵}↵"headers:{content-type:"application/json; charset = utf-8"} request:XMLHttpRequest {onreadystatechange:ƒ,readyState :4,超时:0,withCredentials:false,上传:XMLHttpRequestUpload,...}状态:203 …

javascript slim reactjs axios

12
推荐指数
5
解决办法
4万
查看次数

ReactJS:未捕获的ReferenceError:未定义Set

在某些浏览器上我只能得到

未捕获的ReferenceError:未定义Set.

它是使用create-react-app创建的reactjs应用程序.

为什么我仍然得到错误?
我如何使用polyfill?
反应是否默认使用polyfill?

webpack.config.prod.js

entry: [require.resolve('./polyfills'), paths.appIndexJs],
Run Code Online (Sandbox Code Playgroud)

polyfills.js

'use strict';

if (typeof Promise === 'undefined') {
  // Rejection tracking prevents a common issue where React gets into an
  // inconsistent state due to an error, but it gets swallowed by a Promise,
  // and the user has no idea what causes React's erratic future behavior.
  require('promise/lib/rejection-tracking').enable();
  window.Promise = require('promise/lib/es6-extensions.js');
}

// fetch() polyfill for making API calls.
require('whatwg-fetch');

// Object.assign() is commonly used with React.
// It …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

8
推荐指数
1
解决办法
5788
查看次数

从 GIF 转换为 MP4 时的 FFmpeg 帧速率

我有一个\xc2\xa0GIF 图像。我正在尝试将其转换为 MP4。

\n\n
ffmpeg -f image2 -r {delay_time_of_gif_between_each_frame}/1 -i temp/%05d.png -vcodec libx264 video.mp4\n
Run Code Online (Sandbox Code Playgroud)\n\n

与原始 GIF 相比,该 MP4 的运行速度不同。如何让它以相同的速度运行?

\n\n

看来我在财产方面犯了错误-r。我玩过它,但没有得到任何有用的东西。我什至把它删除了。但它仍然不起作用。

\n

ffmpeg

5
推荐指数
1
解决办法
7569
查看次数

visual studio/apache cordova - 构建成功 - 但没有生成apk

Apache Cordova - Visual Studio 2015 - 无法构建签名的apk

在上面的链接中,我问了一个问题.我无法生成签名的apk.
然后,我发现我需要在build.json文件中输入密钥库.

在那之后,我得到了一些其他错误.所以,我将nodejs版本更新为5.3.0
现在,

begin snippet: js hide: false -->

 language: lang-html -->

     Build started: Project: SignedTest, Configuration: Release Android ------
     Your environment has been set up for using Node.js 5.3.0 (ia32) and npm.
     Ensuring correct global installation of package from source package directory: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\APACHECORDOVATOOLS\packages\vs-tac
    Name from source package.json: vs-tac
     Version from source package.json: 1.0.16
    Package already installed globally at correct version.
     Cordova …
Run Code Online (Sandbox Code Playgroud)

android visual-studio-2015 apache-cordova

5
推荐指数
1
解决办法
840
查看次数

如何在ReactJS组件中动态加载json?

网址是动态的

url/:id/:name(使用 Reach 路由器)

url/1/name1  
url/2/differnet-link  
url/3/another-link
Run Code Online (Sandbox Code Playgroud)

在文章组件中,我想加载1.json如果URL是url/1/name1或者2.json如果URL ID是2

import menuArray from '../data/menu.json';
Run Code Online (Sandbox Code Playgroud)

这就是我通常在 ReactJS 中加载 JSON 的方式

class Article extends React.Component {
    constructor(props) { 
       super(props);
       if(/* id is available in the menuArray */) {
          // I want to load the JSON by id and store it in state
       }  
    } 
}
Run Code Online (Sandbox Code Playgroud)

在 ReactJS 中加载动态 JSON 文件的最佳解决方案是什么?

reactjs

4
推荐指数
1
解决办法
9755
查看次数

Firebase:匿名身份验证 - 如何设置标识符?

const promise = firebase.auth().signInAnonymously();
Run Code Online (Sandbox Code Playgroud)

这是我用来创建匿名身份验证的代码.
我得到了访客的名字,我必须存储

const user_id = response.uid;
const userPromise = firebase.database().ref('users/' + user_id).set({
                    username: this.state.name
                });
Run Code Online (Sandbox Code Playgroud)

response.uid来自承诺.
再次,当用户再次访问该网站时

firebase.auth().onAuthStateChanged(user => {
Run Code Online (Sandbox Code Playgroud)

我必须首先获取uid,我需要使用firebase api来获取用户名.是否可以在标识符列中存储用户名?

javascript firebase firebase-authentication

3
推荐指数
1
解决办法
817
查看次数