javascript 如何更改 dropzone.js 中的默认文本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20287899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 18:09:10  来源:igfitidea点击:

How to change the default text in dropzone.js?

javascriptdropzone.js

提问by Nicklas Pouey-Winger

I'm having trouble changing the default text of my dropzone uploader. Despite the fact that I've initialized it like this, it's still rendering the default text:

我在更改 dropzone 上传器的默认文本时遇到问题。尽管我已经像这样初始化了它,但它仍然呈现默认文本:

Dropzone.options.imgUpload = {
    paramName: "file", // Must match the name of the HttpPostedFileBase argument that the Upload action expects.
    dictDefaultMessage: "Drag your image here",
    acceptedFiles: "image/*" // Accept images only
};

Also tried changing the dictDefaultMessage set in dropzone.js, but with no luck :( By the way; am I supposed to use both or remove one of them?

还尝试更改 dropzone.js 中设置的 dictDefaultMessage,但没有运气:( 顺便说一句;我应该同时使用两者还是删除其中一个?

Any suggestions?

有什么建议?

回答by Nicklas Pouey-Winger

Solved this by including the basic.cssfile alone. This does not render the sprites and you have full control of styling inside the dropzone (It just gives jo a basic skeleton to improve upon). When doing this, dictDefaultMessageis displayed.

通过basic.css单独包含文件解决了这个问题。这不会渲染精灵,并且您可以完全控制放置区内的样式(它只是为 jo 提供了一个需要改进的基本骨架)。执行此操作时,dictDefaultMessage会显示 。

回答by melc

This is based on the documentation of dropzone.js (enter link description here)

这是基于 dropzone.js 的文档(在此处输入链接描述

(without styles)http://jsfiddle.net/44pnR/1/

(不带样式)http://jsfiddle.net/44pnR/1/

HTML

HTML

<form action="/file-upload"
      class="dropzone"
      id="img-upload"></form>

JS

JS

/*"imgUpload" is the camelized version of the HTML element's ID*/
Dropzone.options.imgUpload  = {
    paramName: "file", // Must match the name of the HttpPostedFileBase argument that the Upload action expects.
    dictDefaultMessage: "custom message",
    acceptedFiles: "image/*" // Accept images only
};

回答by Joseph Gill

The only thing that worked for me is to add:

唯一对我有用的是添加:

<div class="dz-message" data-dz-message><span>Drag your image here!</span></div>

<div class="dz-message" data-dz-message><span>Drag your image here!</span></div>

into my HTML file.

进入我的 HTML 文件。

回答by dhawalBhanushali

Adding anything with class as "dz-message" will replace the original text.

添加任何类为“dz-message”的内容将替换原始文本。