我正在尝试使用docker-compose在运行于docker容器中的快速应用程序中启动puppeteer。
应该启动puppeteer的行将const browser = await puppeteer.launch({args: ['--no-sandbox']});引发以下错误:
(node:28) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): AssertionError [ERR_ASSERTION]: Chromium revision is not downloaded. Run "npm install"
我试着加入yarn add puppeteer后yarn install,也更换yarn install在Dockerfile用npm install。
需要进行哪些更改,以便我可以按预期使用木偶和铬?
FROM node:8
RUN apt-get update
# for https
RUN apt-get install -yyq ca-certificates
# install libraries
RUN apt-get install -yyq libappindicator1 libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 …Run Code Online (Sandbox Code Playgroud) 我正在使用几个外部库在vue应用程序中使用工具提示构建图表.我正在使用单文件组件
我有一个工作小提琴,但无法将其翻译成一个工作组件.
在<head>标记中加载3个工具提示实现的脚本
"TypeError: tooltipAnchor.tooltip is not a function"在<body>标记之前加载3个工具提示实现的脚本,然后标记为已编译的vue代码(build.js)
"TypeError: tooltipAnchor.tooltip is not a function"Chart.vue在mounted钩子中的组件中加载3个工具提示实现的脚本
"TypeError: tooltipAnchor.tooltip is not a function"Chart.vue:
mounted: function mounted() {
this.loadJS('https://code.jquery.com/jquery-3.2.1.slim.min.js')
.then(() => {
console.log('jquery loaded');
return this.loadJS('https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js');
})
.then(() => {
console.log('popper loaded');
return this.loadJS('https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js')
})
.then(() => {
console.log('bootstrap loaded');
this.buildChart();
});
},
methods: {
loadJS: function loadJS(url) {
return this.$http.get(url);
}
...
}
Run Code Online (Sandbox Code Playgroud)
需要顶部的所有三个脚本Chart.vue:
我有一组父子 vue 组件。子进程发出一个由父进程处理的事件。我想测试它是否正确处理自定义事件,但我陷入困境。
家长.vue
<template>
<div id="app" class="container">
<!-- phonebook -->
<ChildComponent
class="row mt-4"
@customEvent="val => customEventHandler(val)"
></ChildComponent>
</div>
</template>
<script>
import ChildComponent from './components/ChildComponent.vue'
export default {
name: 'App',
components: {
ChildComponent,
},
data() {
return {
test: [1, 2, 3, 4]
};
},
methods: {
customEventHandler(id) {
// removes item `id` from the `test` array
this.test = this.test.filter((item) => item !== id);
},
}
};
</script>
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的一件事:
父规范.js
import { mount, shallowMount } from "@vue/test-utils";
import Parent from …Run Code Online (Sandbox Code Playgroud) 在由通过docker-compose运行的多个微服务组成的应用程序中,我需要一种方法来从一个容器(app通过flask和请求)直接向另一个容器(chart/ django)发出请求:
这是我正在尝试的简化版本。
route.py:
@APP.route('/post_data', methods=['POST'])
def post_data():
post_data = request.get_json()
response = requests.post('http://chart_app_1:8080/json/', data=post_data)
return response.text
Run Code Online (Sandbox Code Playgroud)
我得到的响应是一条错误消息:
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'chart_app_1:8080'. The domain name provided is not valid according to RFC 1034/1035
Run Code Online (Sandbox Code Playgroud)
我能够毫无问题地向其他运行flask应用程序的容器发出这种请求。但是,对于我们是否将Django用于此特定微服务,我没有任何控制权。
看来这可能是因为主机名中带有下划线:请参阅本文。有没有解决的办法?似乎必须在容器之间发出简单的请求。
我试图弄清楚 js filter() 是如何工作的。
我有一个 API,它返回如下内容:
[
{
"name": "Category 1",
"items": [
{
"name": "Vacancy item #1",
"location": "Los Angeles",
"overview": "Lorem ipsum",
"get_absolute_url": "/careers/vacancy-item-1/"
},
{
"name": "Vacancy item #2",
"location": "Los Angeles",
"overview": "Lorem ipsum",
"get_absolute_url": "/careers/vacancy-item-2/"
}
]
},
{
"name": "Category 2",
"items": [
{
"name": "Vacancy item #3",
"location": "Washington D.C",
"overview": "Lorem ipsum",
"get_absolute_url": "/careers/vacancy-item-3/"
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
我想根据表单的选择值过滤这些数据。我正在研究 VUE.JS 和 Django。
这是我的 JS 代码
filteredItems() {
let vacancycategories = this.listData,
city …Run Code Online (Sandbox Code Playgroud) 我正在使用需要sudo大多数docker命令的远程计算机。我经常必须执行多个重复命令来停止Docker容器等:sudo docker stop <container_name>。
通常,我会docker stop $(docker ps -q)停止的所有结果docker ps -q,但是仅在sudo前面加上前缀并不能满足我的需求:sudo docker stop $(docker ps -q)导致权限被拒绝错误。
有没有办法通过sudo传递它,这样我就不必单独停止所有操作了?
docker ×3
vue.js ×3
django ×2
javascript ×2
bash ×1
bootstrap-4 ×1
filter ×1
flask ×1
jestjs ×1
jsfiddle ×1
linux ×1
node.js ×1
plottable.js ×1
puppeteer ×1
unit-testing ×1