我正在尝试用猫鼬和快递建立一个带有评论系统的简单博客。这里没有创建和发布博客的问题,每个帖子都可以正确显示。但是,有一些与评论和每个博客相关的问题。评论和博客帖子之间的关系是通过在帖子架构中应用 mongoose.Schema.Types.ObjectId 来建立的,并且已经创建了评论来存储评论 id 数组。我认为架构结构是正确的,我的路由代码中可能存在一些问题,请帮助,谢谢。
// Post Schema
const mongoose = require('mongoose');
const postSchema = new mongoose.Schema({
title: {
type: String,
trim: true,
required: true
},
text: {
type: String,
trim: true,
required: true
},
date: {
type: Date,
default: Date.now
},
comments: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'Comment'
}]
})
postSchema.virtual('url').get(function(){
return '/post/' + this._id
})
module.exports = mongoose.model('Post', postSchema);
// Comment Schema
const mongoose = require('mongoose');
const commentSchema = new mongoose.Schema({
text: {
type: String,
trim: true,
required: true …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Javascript构建一个简单的计算器,并且我在清除显示内容时遇到问题.
有人可以看看我的代码,让我知道它为什么不起作用.
为什么不将显示值设置为空字符串.我究竟做错了什么?坦克你们.
function testing(button){
var x = button.value;
document.getElementById("display").innerHTML+=x;
}
function clear() {
document.getElementById("display").innerHTML = "";
}Run Code Online (Sandbox Code Playgroud)
<body>
<input type="button" id="one" value="1" onClick="testing(this)">
<input type="button" id="one" value="2" onClick="testing(this)">
<input type="button" id="one" value="3" onClick="testing(this)">
<input type="button" id="clear" value="clear" onClick="clear()">
<h1 id="display"></h1>
</body>Run Code Online (Sandbox Code Playgroud)
我正在尝试打印一个数组,我想我的所有代码都是正确的,不知道为什么我得到的结果如下...我的代码是
public class App {
public static void main(String[] args) {
int[] array = new int[8];
for (int i = 0; i< array.length; i++){
array[i] = i;
System.out.print("| " + array + " ");
}
System.out.println(" ");
}
}
Run Code Online (Sandbox Code Playgroud)
但我打印的结果如下,为什么?
| [我@ 15db9742 | [我@ 15db9742 | [我@ 15db9742 | [我@ 15db9742 | [我@ 15db9742 | [我@ 15db9742 | [我@ 15db9742 | [I @ 15db9742
calculator ×1
html ×1
innerhtml ×1
java ×1
javascript ×1
mongodb ×1
mongoose ×1
node.js ×1
schema ×1