将组件添加到入口点时出现问题,此错误立即在此处弹出,该如何解决?我也尝试仅添加Main组件,但是无论如何我都会遇到该错误,在main.jsx中,仅带有渲染方法的类返回“ hello world”
_react.default.createContext is not a function
Run Code Online (Sandbox Code Playgroud)
_react.default.createContext is not a function
Run Code Online (Sandbox Code Playgroud)
Webpack配置
'use strict';
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
devtool: 'eval-source-map',
entry: [
'webpack-hot-middleware/client?reload=true',
path.join(__dirname, 'src/app.jsx')
],
resolve: {
root: [
path.resolve(__dirname, "src"),
],
extensions: ['', '.js', '.jsx', '.css']
},
output: {
path: path.join(__dirname, '/public/'),
filename: '[name].js',
publicPath: '/'
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.tpl.html',
inject: 'body',
filename: 'index.html'
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new …Run Code Online (Sandbox Code Playgroud) 我尝试使用类型脚本为 vue 添加 self 插件。
但是当我使用 vue 原型中的方法时,我的方法$auth在 myComponent 类型上不存在。我还为插件添加了.d.ts,但我认为他有点不正确,而且我认为插件不需要使用安装,还是需要?只是在一些例子中我没有看到安装,但在文档中说 - 需要使用安装。
我的插件
import _Vue from 'vue';
import store from '@/store'
import * as firebase from 'firebase';
export default {
install: (Vue: typeof _Vue, options?: any) => {
const base = firebase.initializeApp(config);
const auth = firebase.auth();
Vue.prototype.$auth = {
login: async (username: string, pass: string) => {
return await auth.signInWithEmailAndPassword(username, pass)
},
logout: async () => {
await auth.signOut()
}
};
auth.onAuthStateChanged((user: any) => {
store.commit('updateUser',{ user }) …Run Code Online (Sandbox Code Playgroud) 如果我在电影页面上
/movie/some-movie
Run Code Online (Sandbox Code Playgroud)
并继续链接到
/movie/another-movie
Run Code Online (Sandbox Code Playgroud)
组件未渲染
反应路线v4
路由器
<Route exact path="/movie/:urlRusLat" component={Movie} />
Run Code Online (Sandbox Code Playgroud)
链接
<Link to={'/' + item.media_type + '/' + urlRusLat(item.title || item.name) + '-' + item.id} className="result-element" key={index}>
Run Code Online (Sandbox Code Playgroud)
我尝试使用componentWillReceiveProps并发送请求,但是我在props的新位置接收消息,例如nextProps。
/movie/some-movie
Run Code Online (Sandbox Code Playgroud)
如果路径更改或重新渲染组件,如何发出发送请求?
在 heder 中有一个带有实时搜索的组件,其中有找到的电影或电视剧的链接,具体取决于来自服务器的内容。
Use react-route v4
Run Code Online (Sandbox Code Playgroud)
urlRusLat - 只是一个返回翻译名称电影的函数
<div>
<Helmet>
<title>Movie-search</title>
</Helmet>
<Nav/>
<Header/>
<Switch>
<Route exact path="/" component={Main} />
<Route exact path="/movie/:urlRusLat" component={Movie} />
</Switch>
</div>
Run Code Online (Sandbox Code Playgroud)
和搜索结果中的链接
<Link to={item.media_type + '/' + urlRusLat(item.title || item.name) + '-' + item.id} className="result-element" key={index}>
Run Code Online (Sandbox Code Playgroud)
当我在电影页面上并从搜索中选择某些内容时,我的路径就变成了这样
/movie/some-movie/movie/some-movie
Run Code Online (Sandbox Code Playgroud)
怎么做,当我点击 /move/some-movie 中的链接时
/movie/some-movie
Run Code Online (Sandbox Code Playgroud)
如何不重复路径?
需要找到左括号和右括号,如果违反了左括号和右括号的顺序,则返回false。
但是如果不恢复右数组与左数组进行比较,我不会在这里做检查括号{[(3+1)+2]+}。如果像现在这样反转,那么我无法在这里检查[1+1]+(2*2)-{3/3}
function brackets(expression){
let leftArr=[];
let rightArr = [];
for(let i=0; i<expression.length; i++){
if(expression[i] === '(' || expression[i] === '[' || expression[i] === "{"){
leftArr.push(expression[i]);
}
if(expression[i] === ')'){
rightArr.push("(");
}else if(expression[i] === '}'){
rightArr.push("{");
} else if(expression[i] === ']'){
rightArr.push("[");
}
}
rightArr.reverse();
if(leftArr.length<rightArr.length || leftArr.length>rightArr.length){
return false;
}
for(let k=0; k<leftArr.length; k++) {
if(leftArr[k] != rightArr[k]){
return false;
}
}
return true;
}
console.log(brackets('(3+{1-1)}')); // false
console.log(brackets('{[(3+1)+2]+}')); //true
console.log(brackets('[1+1]+(2*2)-{3/3}')); //true
console.log(brackets('(({[(((1)-2)+3)-3]/3}-3)')); //falseRun Code Online (Sandbox Code Playgroud)
我有一个带有一些值和两个组成部分的商店。红色值更改后需要调用函数时,第一个组件是范围滑块,第二个组件是组件。
在第一个组件中,我更改滑块值并将其添加到vuex存储中。
state: {
value: 0,
rgbColors: {
red: 0
}
},
Run Code Online (Sandbox Code Playgroud)
我如何理解我需要使用store.subscribe.watch.rgbColors.red或store.watch.rgbColors.red,它是正确的吗?
而如果正确更改值后如何调用某些函数呢?
如何找到该对象中所有值的总和?在包含对象的数组中,另一个对象具有值,并且可以是具有相似结构对象的“下一个”数组。
{
value: 4,
next: [
{
value: 3,
next: [...]
},
{
value: 3,
next: [...]
},
...
]
}
Run Code Online (Sandbox Code Playgroud) 我尝试从本地项目调用我的测试函数。
但是每次我打电话时,我都会收到 401 错误。我不知道这里有什么麻烦,在前端我有带 api 密钥的 init 应用程序,在我有 firebase 功能admin.credential.applicationDefault();我试图通过admin.credential.cer(apiConfig),但这无济于事。
我也有环境变量GOOGLE_APPLICATION_CREDENTIALS,带有我的配置路径。
依赖关系
"firebase-admin": "~7.0.0",
"firebase-functions": "^2.2.0",
"firebase-functions-test": "^0.1.6",
Run Code Online (Sandbox Code Playgroud)
我的功能
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp({
credential: admin.credential.applicationDefault(),
databaseURL: "https://plan-list.firebaseio.com"
});
exports.createInviteUser = functions.https.onCall( (data, context)=> {
return data;
});
Run Code Online (Sandbox Code Playgroud)
前端功能请求
createInviteUser(email: string) {
let inviteFunction = firebase.functions().httpsCallable('createInviteUser');
inviteFunction(email)
.then((result) => {
// Read result of the Cloud Function.
console.log(result);
})
.catch(err=>{
console.log(err)
});
}
Run Code Online (Sandbox Code Playgroud)
另外,我怎么看我有所有必需的标题
12:54:58.063 …Run Code Online (Sandbox Code Playgroud) firebase firebase-authentication google-cloud-functions google-cloud-firestore
javascript ×3
reactjs ×3
react-router ×2
vue.js ×2
vuejs2 ×2
firebase ×1
react-redux ×1
typescript ×1
vuex ×1