当我在本地运行 jest 测试时yarn test:unit:watch,我从 jest 库中收到此错误:
Test suite failed to run
TypeError: Cannot redefine property: window
at Object.<anonymous> (node_modules/jest-canvas-mock/lib/index.js:11:17)
Run Code Online (Sandbox Code Playgroud)
有什么建议吗?有什么问题吗?我尝试删除 node_modules 并重新安装,并再次克隆存储库,但它正在重复。其他人则没有面临这个问题。
我正在尝试将我的ajax调用重写为fetch:
阿贾克斯:
$.post({
context: this,
url: "/api/v1/users",
data: {
user:
{
email: email,
password: password
}
}
}).done((user) => {
}).fail((error) => {
})
Run Code Online (Sandbox Code Playgroud)
取:
fetch('/api/v1/users', {
method: 'POST',
headers: {
"Content-Type": "application/json"
},
body: {
"user" :
{
"email" : email,
"password" : password
}
}
})
.then(res => {
if (res.status !== 200) { {
console.log("error")
})
} else {
res.json().then(data => {
console.log(data)
})
}
})
Run Code Online (Sandbox Code Playgroud)
我从我的服务器收到错误空params〜错误请求.
我也找到了这种方法,但在下面的代码中我得到一个错误:意外的令牌.
var payload = {
"user" :
{
"email" : …Run Code Online (Sandbox Code Playgroud) 我使用Materialize css框架选择表单时遇到问题.这是我的表格:
<div class="input-field col s12">
<select multiple>
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label>Materialize Multiple Select</label>
</div>
<script src="//code.jquery.com/jquery-2.1.2.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js"></script>
<script>
$('select').material_select();
</script>
Run Code Online (Sandbox Code Playgroud)
这是我的苗条布局:
doctype html
html
head
meta content=("text/html; charset=UTF-8") http-equiv="Content-Type" /
title Budeprace
= stylesheet_link_tag 'https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css', media: 'screen,projection'
= stylesheet_link_tag 'http://fonts.googleapis.com/icon?family=Material+Icons'
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true
= csrf_meta_tags
meta content="width=device-width, initial-scale=1.0" name="viewport"
body
.container
- flash.each do …Run Code Online (Sandbox Code Playgroud) 我有这个 html 按钮:
<button
type='button'
class="button-name"
(click)="change($event)"
[disabled]='disabledButton'
>
Run Code Online (Sandbox Code Playgroud)
我在打字稿中有这个:
change(event: Event) {
console.log(event);
}
Run Code Online (Sandbox Code Playgroud)
问题是当我在这个按钮上按下 ENTER 时,它会触发鼠标事件而不是键盘事件:
MouseEvent {type: "click", target: ..., ...}
Run Code Online (Sandbox Code Playgroud)
为什么它会在 Enter 时触发 MouseEvent?改变它的最好方法是什么?该按钮绝对应该在键盘和鼠标上都可以使用,但是由于一些跟踪和 a11y 在后台运行,这会导致不正确的行为。
感谢任何可以进一步解释为什么它是 MouseEvent 并提出一些解决方案的人。
我的应用程序中有适用于Paperclip gem的文档(pdf,doc)。我需要通过邮寄请求将文档传递给其他第三方应用程序。
我试图通过Base64转换回形针附件,但会引发错误:没有将Tempfile隐式转换为String
这是我的做法:
# get url from the paperclip file
url = document.doc.url # https://s3-ap-southeast-1.amazonaws.com/xx-eng/documents/xx/000/000/xx/original/doc.pdf
file_data = open(url)
# Encode the bytes to base64 - this line throw error
base_64_file = Base64.encode64(file_data)
Run Code Online (Sandbox Code Playgroud)
您对如何避免Tempfile错误有任何建议?