我正在使用 Laravel 和 Vue.js 开发一个应用程序。我在数据库中有一些数据,例如Hello <b>world!</b>
. 我如何将它们显示为 Hello world!?
这是我在我的应用程序中使用的常见模式.
const data = [{
id: 1234,
name: 'item1',
condition: true
},
{
id: 1235,
name: 'item2',
condition: false
},
{
id: 1236,
name: 'item3',
condition: true
}
]
//filters into array of ids of objects that meet condition
const onlyIds = data.reduce((idArr, item) => {
item.condition && idArr.push(item.id)
return idArr;
}, [])
console.log(onlyIds);
Run Code Online (Sandbox Code Playgroud)
我很好奇是否有我可以意识到的优化?
我很好奇的一些优化,可靠性,可读性,性能和口才.我是否应该考虑进行其他优化?
display = document.getElementById('outputDiv');
display.innerHTML = 'Your Number Is: ';
function clear() {
document.getElementById("outputDiv").innerHTML = "";
}
Run Code Online (Sandbox Code Playgroud)
<input type="button" value="Calculate" onclick="calculator()">
<input type="reset" value="Clear" onclick="clear()">
<div id="outputDiv"></div>
Run Code Online (Sandbox Code Playgroud)
单击重置按钮后,我要删除display.innerHTML ='您的号码为:'+总计;
我正在运行以下代码并得到意外的结果:
var a = 1, b =2 ,c = 3;
console.log(5*a+ b>0?b:c);
Run Code Online (Sandbox Code Playgroud)
我有一个简单的If语句,用于检查是否在click事件中调用了复选框,但是click事件似乎不起作用.
我有两个虚拟警报,只是为了看它是否被击中,但它们都不是.
HTML:
<input id="cookie-checkbox" name="cookie-checkbox" class="cookie-checkbox" type="checkbox" checked><label for="cookie-checkbox">I give consent for the use of cookies on this website.</label><br /><br />
<button id="cookiesbutton" type="button" class="btn btn-default">Send</button>
Run Code Online (Sandbox Code Playgroud)
JS:
(function () {
$('#cookiesbutton').click(cookiesDismiss());
});
function cookiesDismiss() {
var cookieConsent = $('#cookie-checkbox');
if (!cookieConsent.checked) {
alert("Cookie removed");
}
else
{
alert("Modal hidden");
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个小提琴设置代码:JSFiddle
我几乎可以肯定我错过了一些真正的,非常小而简单的东西,但我似乎无法看到它.