我正在尝试获取 Firebase 上传的进度,但我试图观察状态的函数显然是在错误的对象类型上调用的:
Uncaught TypeError: uploadTask.on is not a function
at VueComponent.submitUpload (eval at 100 (:8080/1.346d5d05d7c5f84c45e7.hot-update.js:7), <anonymous>:231:15)
at boundFn (eval at <anonymous> (app.js:808), <anonymous>:125:14)
at VueComponent.invoker (eval at <anonymous> (app.js:808), <anonymous>:1659:18)
at VueComponent.Vue.$emit (eval at <anonymous> (app.js:808), <anonymous>:1930:16)
at VueComponent.handleClick (eval at <anonymous> (app.js:1765), <anonymous>:6448:13)
at boundFn (eval at <anonymous> (app.js:808), <anonymous>:125:14)
at HTMLButtonElement.invoker (eval at <anonymous> (app.js:808), <anonymous>:1659:18)
Run Code Online (Sandbox Code Playgroud)
这是我上传文件的方式:
submitUpload: function(){
var files = this.$refs.upload.uploadFiles;
var storageRef = storage.ref();
var pdfsRef = storageRef.child('files');
var file = files[0]['raw'];
var name …Run Code Online (Sandbox Code Playgroud) 我使用Python 3.3.刚下载并安装了ghostscript 32位(GPL发布),但我无法导入它.
我正在使用命令:
import ghostscript
Run Code Online (Sandbox Code Playgroud)
我收到错误:
ImportError: No module named ghostscript
Run Code Online (Sandbox Code Playgroud)
我用资本'G'试了一下,但仍然行不通.有任何想法吗?
我在Django遇到了一个与DB有关的问题,我不明白.
我定义了一个MPTT模型:
class Image(MPTTModel):
name = models.CharField(max_length=50)
parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
def __unicode__(self):
return self.name
def rank(self): leaves = self.get_leafnodes() if leaves: rank = leaves[0].get_level() - self.get_level() else: rank = 0 return rank
mptt.register(Image, order_insertion_by=['name'])
Run Code Online (Sandbox Code Playgroud)
然后在我的视图中,我尝试使用模型的一些语句,并得到一个OperationalError.
def index(request):
if request.method == 'POST':
image_string = request.POST.get('get_image')
index = image_string.find('(')
if index == -1:
parent = image_string
child = None
else:
parent = image_string[0:index]
child = image_string[index+1:len(image_string)-1]
try:
images = Image.objects.all()
image_names = [a.name for a in images]
except Image.DoesNotExist: …Run Code Online (Sandbox Code Playgroud) 我正在尝试按照本教程进行操作
我有以下代码使用Selenium打开一个firefox浏览器:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://localhost:8000')
assert 'Django' in browser.title
Run Code Online (Sandbox Code Playgroud)
但是,Firefox会打开一个恼人的Windows 10'欢迎'页面,并且永远不会访问我指定的URL.我该如何解决这个问题?
当我添加{% extends "X.html" %}到我的子模板(父级是"base.html")时,只加载父模板.当我拿走它时,加载子模板.我有另一个应用程序,我有一个看似相同的继承结构,所以我很难过.这是"base.html":
<!DOCTYPE html>
{% load staticfiles %}
<html>
<head>
{% block js %}
<script src="{{ STATIC_URL }}js/jquery.1.12.4.min.js"></script>
<script src="{{ STATIC_URL }}js/p5.js"
{% endblock %}
<title>myapp</title>
</head>
<body>
<h1>Welcome to my app</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是"grow.html"
<!DOCTYPE html>
{% extends "app/base.html" %}
{% block js %}
<script src="{{ STATIC_URL }}js/grow.js"></script>
{% endblock %}
{% block content %}
<body>
<div id="message" style="visibility: hidden;"></div>
<div id="tree"></div>
<a href="/register/">register</a>
<form method="POST">
{% csrf_token %}
<input type="text" id="txt" />
<input type="submit" …Run Code Online (Sandbox Code Playgroud) 我试图使用递归函数重新定义Javascript的reduce.这是我的尝试,但不起作用.如果有人可以稍微改变它以使其工作,那将是很好的,因为我会更好地理解它.(这是功能-javascript-workshop中的练习).
function reduce(arr, fn, initial) {
if (arr.length) {
var newArr = arr.slice(1, arr.length);
return reduce(newArr, fn, fn(arr[0]));
} else {
return initial;
}
}
module.exports = reduce
Run Code Online (Sandbox Code Playgroud)
它给了我以下隐秘的错误消息,我不知道如何解释:
/usr/local/lib/node_modules/functional-javascript-workshop/exercises/basic_recursion/exercise.js:13
prev[curr] = ++prev[curr] || 1
^
TypeError: Cannot create property 'undefined' on string 'exercitation'
at /usr/local/lib/node_modules/functional-javascript-workshop/exercises/basic_recursion/exercise.js:13:29
at reduce (/home/david/node-school/functional-workshop/solution.js:7:28)
at /usr/local/lib/node_modules/functional-javascript-workshop/exercises/basic_recursion/exercise.js:12:10
at obtainResult (/usr/local/lib/node_modules/functional-javascript-workshop/exercises/runner.js:100:21)
at Exercise.<anonymous> (/usr/local/lib/node_modules/functional-javascript-workshop/exercises/runner.js:66:27)
at next (/usr/local/lib/node_modules/functional-javascript-workshop/node_modules/workshopper-exercise/exercise.js:188:19)
at /usr/local/lib/node_modules/functional-javascript-workshop/node_modules/workshopper-exercise/exercise.js:195:7
at Exercise.<anonymous> (/usr/local/lib/node_modules/functional-javascript-workshop/exercises/runner.js:34:5)
at next (/usr/local/lib/node_modules/functional-javascript-workshop/node_modules/workshopper-exercise/exercise.js:188:19)
at /usr/local/lib/node_modules/functional-javascript-workshop/node_modules/workshopper-exercise/exercise.js:195:7
Run Code Online (Sandbox Code Playgroud) 我需要构建一个应用程序,用户可以在应用程序中打开 PDF 文件,即不需要打开新的浏览器窗口。我需要实现一个后退按钮,可能还需要在 PDF 上实现一些覆盖。有谁知道在 Electron 中是否有好的方法来做到这一点?
我对Haskell的看法感到非常兴奋,但我已经不太了解列表理解了.
如果我想找到类似的事实:
P(x):x ^ 2 <3
为什么表达式为[x | x ^ 2 <3]返回[]?我的语法错了吗?
有没有一种简单的方法可以将文件的下载URL上传到Firebase?
(我试过玩上传功能返回的快照,找不到任何东西......)
fileref.put(file).then(function(snapshot){
self.addEntry(snapshot);
/// return snapshot.url???
});
Run Code Online (Sandbox Code Playgroud) 这是一个例子,我从以前的SO问题略有改变:http: //jsfiddle.net/tPjQR/72/
ol {
font-family: Georgia, serif;
}
ol span {
font-family: Arial, sans-serif;
font-size: 17px
}Run Code Online (Sandbox Code Playgroud)
<ol>
<li><span>Entry one</span></li>
<li><span>Entry two</span></li>
<li><span>Entrye three</span></li>
<li><span>Entry five</span></li>
<li><span>Entry six</span></li>
<li><span>Entry Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long</span></li>
</ol>Run Code Online (Sandbox Code Playgroud)
我想排列这些列,这样,无论一列中有多少文本,每列的第一个字符都会排成一行.
例如
不
Entry one
Entry two
Entrye three
Entry five
Entry six
Run Code Online (Sandbox Code Playgroud)
宁
Entry one
Entry two
Entrye three
Entry five
Entry six
Run Code Online (Sandbox Code Playgroud)
有没有办法用列表项执行此操作,还是需要使用表?
我正在尝试从Node中的文件读取。这是我的代码:
const cheerio = require('cheerio');
var fs = require('fs');
var path = process.argv[2];
var glossArr = []
fs.readFileSync(path, {encoding: "utf8"}, function (err, markup){
console.log('function executing')
if (err) throw err;
const $ = cheerio.load(markup);
var glossar = $('body').children().last();
var index = $('body').children().last().prev();
glossar.children().children().children().each(function(i, elem) {
var obj = {};
var container = $(this).children();
var unter = container.children();
var begriff = unter.first().text();
var text = unter.last().text();
obj[begriff] = text;
obj['file'] = path;
glossArr.push(obj)
});
});
console.log('done reading file...')
var glossString = JSON.stringify(glossArr) …Run Code Online (Sandbox Code Playgroud) 我有一个文件夹,里面有几个js文件:
admin$ ls
filterfiles.js filterfiles.js~ program.js program.js~
Run Code Online (Sandbox Code Playgroud)
program.js是一个节点程序,包含以下内容:
var dir = process.argv[2]
var fs = require('fs')
fs.readdir(dir, function(results){console.log(results)})
Run Code Online (Sandbox Code Playgroud)
当我执行以下操作时,为什么我得到null,而不是目录中的文件列表?
admin$ node program.js './'
null
Run Code Online (Sandbox Code Playgroud) javascript ×6
python ×3
django ×2
firebase ×2
node.js ×2
alignment ×1
asynchronous ×1
cheerio ×1
css ×1
django-1.9 ×1
django-mptt ×1
electron ×1
extends ×1
firefox ×1
ghostscript ×1
haskell ×1
html ×1
import ×1
pdf ×1
python-3.x ×1
recursion ×1
reduce ×1
selenium ×1
set ×1
snapshot ×1
sqlite ×1
upload ×1
windows-10 ×1