jQuery.post默認(rèn)的Content-Type是application/x-www-form-urlencoded
,而你的是application/json
還是不行的話請查看 http://blog.csdn.net/hemingwa...
今天剛剛補(bǔ)充了知識:廣播模式中交換器會將消息發(fā)到所有綁定到它上面的隊列中。
檢查下字符串是否包含特定標(biāo)簽字段如<html>
不知道你用的什么框架 我用vue,把websocket對象存vuex就行
1,一般服務(wù)器寫日志都是有一個buffer的,先寫buffer,buffer寫完了再刷盤,不然磁盤受不了,你多刷個幾十次,看看日志會不會寫進(jìn)去,或者reload下。
2,都是訪問日志,只是 host.access.log 是你定義的 site.com 的server域下的訪問日志,access.log 你定義在了http下面,就是所有的server默認(rèn)的訪問日志文件。 server下的配置會優(yōu)先于http下的配置。
https://segmentfault.com/q/10... 這篇文章里寫的方法可以實(shí)現(xiàn),但是初次加載失敗的問題好像一直都有,用了setTimeout,時而可用,時而不可用。
實(shí)際上對于一個問題的結(jié)果,例如操作一個文件,我們只關(guān)心其結(jié)果,完成或者沒有完成.但是獲取這個結(jié)果需要很多個步驟,每個步驟都是有可能出錯的,而且出錯也有相應(yīng)的修復(fù)邏輯
/**
* 判斷一個文件是否存在
* 存在 不存在
* 打開 創(chuàng)建
* 讀取 打不開 打開 創(chuàng)建不了
* 報錯 報錯 (假設(shè)到這一層就不執(zhí)行操作了)
*/
完成上面的邏輯,單純用Promise來寫,將會變得十分繁瑣,保證Promise最后一個then或者catch是我們要的結(jié)果下,
任何比正常邏輯多出的分支必須在一個then或者catch里寫完才可以保證最后的結(jié)果只有一個,例如上面部分邏輯的偽代碼
hasfile.then(()=>{
//返回不同效果的Promise,并且包含flag
let Pro=new Promise(/*對應(yīng)后續(xù)打開文件的代碼*/);
return {
hasfile:true,
pro:pro
}
}).catch(()=>{
let Pro=new Promise(/*對應(yīng)后續(xù)創(chuàng)建文件的代碼*/);
return {
hasfile:false,
pro:pro
}
}).then((result)=>{
//這個時候執(zhí)行的Promise是不一樣的
if(result.flag){
//如果還想繼續(xù)鏈?zhǔn)秸{(diào)用
//只能繼續(xù)包裝一個Promise對象并返回
//如果直接把result.pro的Promise執(zhí)行,那么鏈?zhǔn)秸{(diào)用就到此結(jié)束
return new Promise((resolve,reject)=>{
//這里執(zhí)行的是打開的代碼,但是代碼本體卻是在上一個
//then里寫的
result.then((file)=>{
resolve(file);
}).catch((err)=>{
reject(err)
})
})
}else{
}
})
結(jié)果就是,Promise不適合干帶有過多邏輯分支或者循環(huán)的異步,不然要Generator和async干嘛
第一個問題你看你打印的結(jié)果
第一個是[]空數(shù)組 第二個是[{}]數(shù)組包含一個對象 第三個是[{},{}]包含兩個對象,
但你點(diǎn)擊的時候點(diǎn)的是newlist對象的引用,及指向內(nèi)存區(qū)域的值,因?yàn)槟愕姆椒▓?zhí)行完了所以打開都是包含兩個對象,你可以運(yùn)行一下下面的代碼看一下,第二個問題同第一個問題
var list = [{name:"xiaoming",age:12},{name:"xiaohong",age:13},{name:"dondong",age:15}];
var newlist = [];
for(var i = 0;i<list.length;i++){
if(parseInt(list[i].age) !== 12){
newlist.push(list[i]);
}
console.log(JSON.stringify(newlist));
}
可以微信開發(fā)者工具中查看獲得權(quán)限,是否真的配置是有效的
webstorm全局搜索
initialValue
你在{"comments":{"$slice":1}
這個外面套一層 projection
就可以了。
最終變成findOne({ "_id": ObjectId(user_id)},{projection: {"comments":{"$slice":1}}}
var path = require('path')
var utils = require('./utils')
var webpack = require('webpack')
var config = require('../config')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var CopyWebpackPlugin = require('copy-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
var env = config.build.env
var webpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true
})
},
devtool: config.build.productionSourceMap ? '#source-map' : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js', true),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
sourceMap: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css', true),
allChunks: true
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: {
safe: true
}
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
...utils.getHtmlPlugins(),
// keep module.id stable when vender modules does not change
new webpack.HashedModuleIdsPlugin(),
// split vendor js into its own file
<1.--------------------------------------------------------------------->
// new webpack.optimize.CommonsChunkPlugin({
// name: 'vendor',
// minChunks: function (module, count) {
// // any required modules inside node_modules are extracted to vendor
// return (
// module.resource &&
// /\.js$/.test(module.resource) &&
// module.resource.indexOf(
// path.join(__dirname, '../node_modules')
// ) === 0
// )
// }
// }),
----------------------------------------------------------------------
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
<2.--------------------------------------------------------------------->
// new webpack.optimize.CommonsChunkPlugin({
// name: 'manifest',
// chunks: ['vendor']
// }),
----------------------------------------------------------------------
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
if (config.build.productionGzip) {
var CompressionWebpackPlugin = require('compression-webpack-plugin')
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' +
config.build.productionGzipExtensions.join('|') +
')$'
),
threshold: 10240,
minRatio: 0.8
})
)
}
if (config.build.bundleAnalyzerReport) {
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = webpackConfig
@歐兜兜是素姀 的回答是正確的,mongoose的Schema可以使用required屬性來規(guī)范數(shù)據(jù),這樣不符合要求的數(shù)據(jù)存入mongodb會失敗的。
但是,就算是數(shù)據(jù)庫規(guī)范了,前端也不能假設(shè)數(shù)據(jù)庫返回的數(shù)據(jù)沒問題,前端還是需要對后端返回的數(shù)據(jù)進(jìn)行驗(yàn)證和容錯。因?yàn)榍岸撕秃蠖耸欠蛛x的,前端需要假設(shè)后端會出錯。事實(shí)上,后端出錯也是無法避免的,因?yàn)榇a一直在修改,哪天后端不小心刪掉required字段呢?
你這是微信開發(fā),去微信開發(fā)者中心找找文檔,另外這種涉及隱私的行為估計不能正常獲取
不可以,要么把數(shù)組提到外面去定義,要么在定義obj之后再賦值key5
DRM,直接下載播放不了
React.PureComponent 其實(shí)是重寫了SCU(shouldComponentUpdate)方法。
React.Component shouldComponentUpdate 的實(shí)現(xiàn)是直接返回true。
這就是兩者的區(qū)別。 造成這樣的情況的原因就在于shouldComponentUpdate”錯誤“地將返回值變成false了。
PureComponent 重寫的SCU其實(shí)就是shallow equal 兩個state和nextState,prop和nextProps。
從你的代碼中看,是
let nextIndex=++preState.index;
// 等價于
let nextIndex = preState = preState.index + 1;
因此不僅僅修改了nextIndex, 同時也修改了preState.index.
你可以繼承React.Component,自己寫SCU,然后debug看一下就明白了。
希望我的回答對你有幫助。
打開 HOSTS 文件,添加:
127.0.0.1 你的api所在的域名
這時,如果你的 php代碼已經(jīng)實(shí)現(xiàn)的接口的功能,就應(yīng)該可以正常測試了。
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團(tuán)創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機(jī)構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團(tuán),成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
浪潮集團(tuán)項目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。