这个问题有很多答案,我尝试了我发现的 - 没有用
所以,我试过 sudo mysqld stop。我仍然看到 mysql 进程正在运行:
0 317 1 0 11:15AM ?? 0:00.02 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.pid
74 3562 317 0 11:40AM ?? 0:00.41 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.err --pid-file=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.pid
Run Code Online (Sandbox Code Playgroud)
如果我这样做,也会发生同样的情况 “sudo kill -9 3562”.
尝试转到 /Library/LaunchDaemons 不会检索任何 mysql 条目
ls /Library/LaunchDaemons | grep mysql
Run Code Online (Sandbox Code Playgroud)
服务命令不起作用:
-bash: service: command not found
Run Code Online (Sandbox Code Playgroud)
我的 OS X 版本是 10.9.2
所以我正在关注一些教程,我对使用HOC时事物呈现方式感到困惑
所以首先,我猜道具从父母流向孩子,这是一个方向吗?
在这里,我们创建了两个HOC,即Aux和withclass
辅助人员除了传递道具外没有什么特别的事情。
const aux = (props) => props.children;
export default aux;
Run Code Online (Sandbox Code Playgroud)
withClass HOC函数采用两个参数App和className。
const withClass = (WrappedComponent, className) => {
return class extends Component {
render () {
return (
<div className={className}>
<WrappedComponent {...this.props} />
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud)
作为参数传递的App.js如下所示
import React, { PureComponent } from 'react';
import classes from './App.css';
import Persons from '../components/Persons/Persons';
import Cockpit from '../components/Cockpit/Cockpit';
import Aux from '../hoc/Aux';
import withClass from '../hoc/withClass';
class App extends PureComponent {
//something
render () …Run Code Online (Sandbox Code Playgroud) 我通过遵循一些教程来学习 redux。在这里我收到一个错误
Object(...) 不是函数
在这一行
export default connect(null, { fetchPosts } )(Posts);
Run Code Online (Sandbox Code Playgroud)
以下容器的
import React, { Component } from 'react';
import { connect } from 'react'
import axios from 'axios';
import { fetchPosts } from '../actions/postActions.js';
class Posts extends Component {
componentWillMount() {
this.props.fetchPosts();
}
render() {
const postItems = this.state.posts.map(el => {
return (
<div key={el.id}>
<h3>{el.title} </h3>
<p>{el.body} </p>
</div>
)
})
return (
<div>
<h1> Posts </h1>
{postItems}
</div>
);
}
}
export default connect(null, { fetchPosts …Run Code Online (Sandbox Code Playgroud) 我正在上斯蒂芬·格林德(Stephen Grinder)的高级NodeJS课程,我们在Redis中测试了缓存。
当我运行我的应用程序并到达给定的路线时,我被抛出此错误
弃用警告:猫鼬:mpromise(猫鼬的默认诺言库)已过时,请插入您自己的诺言库:http ://mongoosejs.com/docs/promises.html
另一个看起来像这样
UnhandledPromiseRejectionWarning:未处理的承诺拒绝。该错误是由于在没有catch块的情况下抛出异步函数而引起的,或者是由于拒绝了未经.catch()处理的诺言而引起的。(拒绝ID:1)[0](节点:11896)[DEP0018] DeprecationWarning:已弃用未处理的承诺拒绝。将来,未处理的承诺拒绝将以非零的退出代码终止Node.js进程。[0]来自MongoDb的服务
现在,如前所述,我经过了非常模糊的审视,似乎他们的文档中没有谈论异步和等待。
这是api路线引发错误
app.get('/api/blogs', requireLogin, async (req, res) => {
const redis = require('redis')
const redisURL = 'redis://127.0.0.1:6379';
const client = redis.createClient(redisURL);
const util = require('util')
client.get = util.promisify(client.get)
const cachedBlog = await client.get(req.user.id)
if (cachedBlog) return res.send(JSON.parse(cachedBlogs))
console.log("serving from MongoDb")
const blogs = await Blog.find({_user: req.user.id})
client.set(req.user.id, JSON.parse(blogs))
res.send(blogs);
});
Run Code Online (Sandbox Code Playgroud)
具体来说这行
const blogs = await Blog.find({_user: req.user.id})
Run Code Online (Sandbox Code Playgroud)
哪里
const Blog = mongoose.model('Blog');
Run Code Online (Sandbox Code Playgroud)
注意:为了简略地解释缓存,Stephen Grinder特意将其设置在根目录内。
[问题:]有人可以告诉我如何使用异步/等待(例如我目前在路由内所做的操作)而不会引发任何错误吗?
我试图使用 redis 来理解 NodeJS 中的缓存。
在讲座中,讲师告诉我设置缓存的最佳位置是在 mongoose 中的 exec 函数之前。
所以为了做到这一点,他做了
const mongoose = require('mongoose')
const exec = mongoose.Query.prototype.exec;
//Redis logic
mongoose.Query.prototype.exec = function () {
console.log("i am here")
return exec.apply(this, argument);
}
Run Code Online (Sandbox Code Playgroud)
第一:会分类mongoose.Query.prototype.exec;成什么?值类型还是引用类型?因为如果它是一个引用类型,那么当我们改变时, mongoose.Query.prototype.exec = function它的值不应该也改变吗?
第二,我无法在这里理解这条线return exec.apply(this, argument);有人可以解释这一点,即这适用于哪里?并且他正在传递参数(this, argument);该参数从何而来?
有人可以通过回答上述两个问题来帮助我吗?
我上一篇文章中强调的某些性能建议我参考stackoverflow 中的以下问题避免显式的 Promise 构造反模式
坦白说,我对 JS 和 Node 都是新手,也没有经常使用 Promise。我去读了那些文章,但要么我无法理解或无法联系,要么我对承诺的理解一直模糊/错误
所以我决定在新线程中提出这个问题并寻求帮助。
我正在创建帮助程序/通用函数,我可以用它来保持代码整洁,如果我想随时更改函数内部的任何内容,我不必手动更改每个函数。
这些是我制作的功能
//Find user by email Address
const findUserByEmail = (emailAddress) => {
return new Promise((resolve, reject) => {
User.findOne({email: emailAddress}).then(response => {
resolve(res)
}).catch(error => {
reject("Error in findUserByEmail", error);
})
})
}
//Create User
const createNewUser = (newUserDetails) => {
return new Promise((resolve, reject) => {
new User({
fullName: newUserDetails.fullName,
email: newUserDetails.email,
image: newUserDetails.image,
gender: newUserDetails.gender,
age: newUserDetails.age
}).save().then((response) => { …Run Code Online (Sandbox Code Playgroud) 我正在使用 Vue、Vuex 和 Quasar(Quasar 在这里可能不相关,也可能不相关)
这是我的第一个应用程序,所以我不确定我的做法是否正确
下面是我的路线的代码片段
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
/*
* If not building with SSR mode, you can
* directly export the Router instantiation
*/
const routes = [
{
path: '/',
component: () => import('layouts/MyLayout.vue'),
beforeEnter: ifAuthenticated ,
children: [
{ path: '', component: () => import('./../container/Index.vue') }
]
}
]
const ifNotAuthenticated = (to, from, next) => {
console.log("here")
if (!store.getters.isAuthenticated) return next()
else next('/')
}
const ifAuthenticated = (to, …Run Code Online (Sandbox Code Playgroud) 我想导入两个具有相同名称的模块,即
import {Input, Icon} from 'native-base'
Run Code Online (Sandbox Code Playgroud)
和
import {Input, Button} from 'react-native-elements'
Run Code Online (Sandbox Code Playgroud)
如何在JSX中导入和使用它们两者?可能吗?
在文档中,他们提到
Controls whether the View can be the target of touch events.
• 'auto': The View can be the target of touch events.
• 'none': The View is never the target of touch events.
• 'box-none': The View is never the target of touch events but it's subviews can be. It behaves like if the view had the following classes in CSS:
Run Code Online (Sandbox Code Playgroud)
在这里,我能够从属性中none理解没有触摸事件会起作用,即 touchableOpacity(和其他触摸事件)?那是对的吗?
但是来自 YouTube 上的以下教程视频
https://www.youtube.com/watch?v=aFwBzWV6A-w
看来作者正在使用它禁用诸如 textInput 之类的事件,而不是将其用于诸如 touchableOpactiy 之类的事件。
javascript ×5
node.js ×4
react-native ×3
reactjs ×3
mongoose ×2
promise ×2
asynchronous ×1
express ×1
macos ×1
mongodb ×1
mysql ×1
react-redux ×1
redis ×1
redux ×1
vue.js ×1