所以我有一个容器,我想扩大和缩小(放大和缩小),但也有扩展/收缩形式占用空间而不是只是重叠其他东西.
有一个图像,其中有absolutediv放置在坐标中,它们必须在上下调整时保持它们的相对位置(因此我为什么使用比例).
var b = document.getElementById("outer");
var scale = 1;
function increase() {
scale += 0.1
b.style.transform = `scale(${scale})`;
}
function decrease() {
scale -= 0.1
b.style.transform = `scale(${scale})`;
}Run Code Online (Sandbox Code Playgroud)
#outer {
overflow-x: auto position: relative;
transform-origin: left top;
}
.pointer {
width: 20px;
height: 20px;
background-color: orange;
position: absolute;
}
#a1 {
top: 50px;
left: 150px;
}
#a2 {
top: 150px;
left: 50px;
}
#a3 {
top: 250px;
left: 550px;
}Run Code Online (Sandbox Code Playgroud)
<div>
<button onclick="increase()">Increase</button>
<button onclick="decrease()">Decrease</button> …Run Code Online (Sandbox Code Playgroud)当我使用可选链时,我看到一个红色下划线,但代码运行良好,因为我在节点 14 上
这是我的设置:
node 14.1.0
eslint "^6.8.0"
Run Code Online (Sandbox Code Playgroud)
.eslintrc.js
module.exports = {
"env": {
"node": true
},
"extends": [
"eslint:recommended",
],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2020
},
"rules": {
},
}
Run Code Online (Sandbox Code Playgroud)
所以我有这个代码:
axios({
method: 'post',
url,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
data: {
json,
type,
}
})
Run Code Online (Sandbox Code Playgroud)
最初我有正常axios.post但我改变了这个,因为我认为它可能是一个标题问题.但是我仍然没有检测,我$_REQUEST也没有$_POST.但是,它正在接收数据file_get_contents("php://input").
知道什么是错的吗?
编辑
好吧,我想我知道什么是错的.它将它作为json对象发布,因此只能在php://输入中读取.如何在axios中将其更改为普通字符串?
所以这是我的可观察代码:
var suggestions =
Rx.Observable.fromEvent(textInput, 'keyup')
.pluck('target','value')
.filter( (text) => {
text = text.trim();
if (!text.length) // empty input field
{
this.username_validation_display("empty");
}
else if (!/^\w{1,20}$/.test(text))
{
this.username_validation_display("invalid");
return false;
}
return text.length > 0;
})
.debounceTime(300)
.distinctUntilChanged()
.switchMap(term => {
return $.ajax({
type: "post",
url: "src/php/search.php",
data: {
username: term,
type: "username"
}
}).promise();
}
);
suggestions.subscribe(
(r) =>
{
let j = JSON.parse(r);
if (j.length)
{
this.username_validation_display("taken");
}
else
{
this.username_validation_display("valid");
}
},
function (e)
{
console.log(e);
} …Run Code Online (Sandbox Code Playgroud) 是否可以在 a 的name部分内访问对象的键.each?
let accounts =
[
{
details:
{
company_name:
"company_name",
email,
password:
"asdf",
},
find:
[
"_id",
"company_name",
"email",
"type",
],
type:
"creator"
},
{
details:
{
email,
first_name:
"first_name",
last_name:
"last_name",
password:
"asdf",
},
find:
[
"_id",
"email",
"first_name",
"last_name",
"type",
],
type:
"user"
},
]
describe.each(accounts)(
"%s", // <-- access the 'type' key, e.g. account.type
function (account)
{
// test code
}
)
Run Code Online (Sandbox Code Playgroud) 有对应声明文件的文件是否有可能在vscode中检测自己的类型?
其他文件可以获取类型,但不能获取文件本身。
注意任何
但这有正确的打字
npm initindex.js index.d.ts import.jsindex.js
async function test(input) {
return null
}
Run Code Online (Sandbox Code Playgroud)
index.d.ts
type input_type = {
name: string,
salary: number
}
export function test(input : input_type) : Promise<null>
Run Code Online (Sandbox Code Playgroud)
import.js
import * as t from './index'
t.test()
Run Code Online (Sandbox Code Playgroud)
当您将鼠标悬停在其中的test函数上时,index.js它不知道其参数类型。但在import.js它知道它。
我怎样才能让index.js test函数知道它自己的类型。
有没有办法获得文件的绝对路径,同时将其包含在另一个脚本中?
因此,当我在文件夹B中时,我正在尝试包含文件夹A中的文件,但它一直试图引用文件夹B的位置.
我试过dirname,$SERVER['PHP_SELF'],cwd(),但他们还是回到一个相对路径.
发生的事情是,当我运行我的测试时,我的覆盖范围只显示bundle.js哪些没有用.
我有以下webpack文件设置,并想知道我应该改变什么,以便每个文件都被单独覆盖
webpack.config-test.js
var nodeExternals = require("webpack-node-externals")
const path = require("path")
module.exports = {
context: path.resolve(__dirname),
resolve: {
extensions: [".js"],
alias: {
"@": path.join(__dirname, "../../src/server"),
}
},
output: {
path: "./",
filename: "[name].js",
},
target: "node", // webpack should compile node compatible code
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
}
Run Code Online (Sandbox Code Playgroud)
通过npm运行命令:
nyc mocha-webpack --webpack-config test/server/webpack.config-test.js --glob \"*spec.js\" test/server/unit
Run Code Online (Sandbox Code Playgroud)
目前的输出是:
All files | 90.38 | 70.83 | 90.91 | 90.2 | |
bundle.js …Run Code Online (Sandbox Code Playgroud) 因此,nyc正在修改我的文件,如下所示:
at _onCreate (src/post/admin.js:1:10453)
at doQuery (src/db.js:59:216)
at process._tickCallback (internal/process/next_tick.js:68:7)
Run Code Online (Sandbox Code Playgroud)
我不确定如何使用源地图解开这个.文档说明:
使用源映射准确的堆栈跟踪.
当produce-source-map设置为true时,已检测的源文件将包含instrumenter转换的内联源映射.与源映射支持结合使用时,已检测代码的堆栈跟踪将反映其原始行.
所以我尝试了以下npm run命令:
"NODE_ENV=test nyc mocha --require ./tests/setup.js --require source-map-support/register --produce-source-map true --bail ./tests/unit/$FILE"
Run Code Online (Sandbox Code Playgroud)
结合纽约设置:
"nyc": {
"include": [
"src"
],
"exclude": [
"./tmp/**/*",
"./tests"
],
"instrument": true,
"report-dir": "./tests/coverage",
"temp-dir": "./tests/temp",
"source-map": true,
"produce-source-map": true
}
Run Code Online (Sandbox Code Playgroud)
但线路仍然受损.
所以,如果我把console.log里面test的console.log将测试如后出现
authentication.spec.js
register
? should be able to insert (128ms)
? should fail because of duplicate (100ms)
? should have user id assigned (1ms)
login
? should be able to login for correct user (117ms)
? should fail for incorrect user (14ms)
console.log tests/unit/authentication.spec.js:110
we can see a message
Run Code Online (Sandbox Code Playgroud)
我希望看到的是:
authentication.spec.js
register
? should be able to insert (128ms)
? should fail because of duplicate (100ms)
? should have user id assigned (1ms)
login …Run Code Online (Sandbox Code Playgroud)