如何抓取⼩程序模版html,⼩程序怎么处理爬取得到的数据,包
括html标签样式等...
最近打算做⼩程序,可是发现⼩程序没有能⼒去处理html标签,之前做项⽬⼀直都是⽤vuejs,还可以使⽤v-text或者v-html去处理显⽰html标签,可是在⼩程序中不知道怎么做,⽐如爬取到的数据:
jQuery tagEditor Plugin
body { margin: 0; padding: 0; border: 0; min-width: 320px; color: #777; }
html, button, input, select, textarea, .pure-g [class *= "pure-u"] { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 1.02em; }
p, td { line-height: 1.5; }
ul { padding: 0 0 0 20px; }
th { background: #eee; white-space: nowrap; }
th, td { padding: 10px; text-align: left; vertical-align: top; font-size: .9em; font-weight: normal; border-right: 1px solid #fff; }
td:first-child { white-space: nowrap; color: #008000; width: 1%; font-style: italic; }
h1, h2, h3 { color: #4b4b4b; font-family: "Source Sans Pro", sans-serif; font-weight: 300; margin: 0 0 1.2em; }
h1 { font-size: 4.5em; color: #1f8dd6; margin: 0 0 .4em; }
h2 { font-size: 2em; color: #636363; }
h3 { font-size: 1.8em; color: #4b4b4b; margin: 1.8em 0 .8em }
h4 { font: bold 1em sans-serif; color: #636363; margin: 4em 0 1em; }
a { color: #4e99c7; text-decoration: none; }
a:hover { text-decoration: underline; }
p, pre { margin: 0 0 1.2em; }
::selection { color: #fff; background: #328efd; }
::-moz-selection { color: #fff; background: #328efd; }
@media (max-width:480px) {
h1 { font-size: 3em; }
h2 { font-size: 1.8em; }
h3 { font-size: 1.5em; }
td:first-child { white-space: normal; }
}
.inline-code { padding: 1px 5px; background: #eee; border-radius: 2px; }
pre { padding: 15px 10px; font-size: .9em; color: #555; background: #edf3f8; }
pre i { color: #aaa; } /* comments */
pre b { font-weight: normal; color: #cf4b25; } /* strings */
pre em { color: #0c59e9; } /* numeric */
/* Pure CSS */
.pure-button { margin: 5px 0; text-decoration: none !important; }
.button-lg { margin: 5px 0; padding: .65em 1.6em; font-size: 105%; }
.button-sm { font-size: 85%; }
textarea {
width: 100%; height: 29px; padding: .3em .5em; border: 1px solid #ddd; font-size: .9em;
box-sizing: border-box; margin: 0 0 20px;
}
textarea[readonly] { color: #aaa; background: #f7f7f7; }
#response {
margin: 0 0 1.2em; padding: 10px; background: #f3f3f3; color: #777;
font-size: .9em; max-height: 150px; overflow: hidden; overflow-y: auto;
}
#response i { font-style: normal; color: #cf4b25; }
#response hr { margin: 2px 0; border: 0; border-top: 1px solid #eee; border-bottom: 1px solid #fdfdfd; }
/* overwrite default CSS for tiny, dark tags in demo5 */
#demo5+.tag-editor { background: #fafafa; font-size: 12px; }
#demo5+.tag-editor .tag-editor-tag { color: #fff; background: #555; border-radius: 2px; }
#demo5+.tag-editor .tag-editor-spacer { width: 7px; }
#demo5+.tag-editor .tag-editor-delete { display: none; }
/* color tags */
.tag-editor .red-tag .tag-editor-tag { color: #c65353; background: #ffd7d7; }
.tag-editor .red-tag .tag-editor-delete { background-color: #ffd7d7; }
.tag-editor .green-tag .tag-editor-tag { color: #45872c; background: #e1f3da; }
.tag-editor .green-tag .tag-editor-delete { background-color: #e1f3da; }
tagEditor
A powerful and lightweight tag editor plugin for jQuery.
example tags, sortable, autocomplete, edit in place, tab/cursor navigation, duplicate check, callbacks, copy-paste, placeholder, public methods, custom delimiter, graceful degradation
Overview and Features
Released under the .
Source on ().
Compatible with jQuery 1.7.0+ in Firefox, Safari, Chrome, Opera, Internet Explorer 8+. IE7 technically works, but no care has gone into CSS/layout bugs.
tagEditor depends on accursoft's (1.1 kB minified).
Lightweight: 8.5 kB of JavaScript - less than 3.2 kB gzipped
Edit in place tags
Intuitive navigation between tags with cursor keys, Tab, Shift+Tab, Enter, Pos1, End, Backspace, Del, and ESC Optional jQuery UI sortable
Optional jQuery UI autocomplete
Copy-paste or delete multiple selected tags
Duplicate tags check
Custom delimiter/s
Placeholder
Custom style for faulty tags
Public methods for reading, adding and removing tags + destroy function
Callbacks
Allows tabindex for form navigation
Graceful degradation if JavaScript is disabled
This plugin was developed by and for - an international repository for free Public Domain images.
We have implemented this piece of software in production and we share it - in the spirit of Pixabay - freely with others. Usage
Include the stylesheet jquery.tag-editor.css in the <head> section of your HTML document - and the JavaScript file jquery.tag-editor.min.js after loading jQuery and optional jQuery UI sortable/autocomplete.
Make sure to also load accursoft's (1.1 kB minified).
tagEditor accepts settings from an object of key/value pairs, and can be assigned to any text input field or textarea.
$(selector).tagEditor({key1: value1, key2: value2});
// examples
// assign tag editor to textarea - existing text will be used as initial tags
'textarea').tagEditor();
$('textarea'
// assign tag editor to text input with initial tags
'tag3'] });
'tag2', 'tag3'
'tag1', 'tag2'
'input[type="text"]').tagEditor({ initialTags: ['tag1'
$('input[type="text"]'
// use jQuery UI autocomplete
'/url/', minLength: 3 } });
$('#my_textarea'
'source': '/url/'
'#my_textarea').tagEditor({ autocomplete: { 'source'
Settings
Property Default Description
initialTags[]Initial tags as an array of strings.
maxTags null Maximum number of allowed tags.
maxLength50maxlength attribute of the tag input field.
Required string of delimiters - characters for separating tags.
delimiter',;'
The first character is used as default delimiter in the (hidden) original field.
placeholder''Placeholder text for empty tag editor.
html document是什么forceLowercase true Lowercase all tags.
removeDuplicates true Automatically remove duplicate tags.
clickDelete false Delete tags on right click and on Ctrl+click.
animateDelete175Animate duration for deletion of tags in milliseconds. Set to 0 for non-animated removal.
sortable true If is available and this option is set to true, tags are sortable by drag and drop.
autocomplete null options as key/value pairs object. If provided, jQuery UI autocomplete must be loaded additionally. Callbacks
onChange(field, editor, tags)Callback that fires after tags are changed. field is the (hidden) original field, editor is the editor's DOM element (an <ul> list of tag elements), and tags contains the list of current tags.
beforeTagSave(field, editor, tags, tag, val)Callback that fires before a tag is saved. field is the (hidden) original field, editor is the editor's DOM element. tags contains the list of current tags, tag is the value that is about to get overwritten (empty string, unless an existing tag gets changed), and val is the new value to be saved. beforeTagSave() may return a string for overwriting the saved tag. Return false for reverting to the tag's previous value (or to skip this tag value in the case of copy-paste insertion).
beforeTagDelete(field, editor, tags, val)Callback that fires before a tag is deleted. field is the (hidden) original field, editor is the editor's DOM element. tags contains the list of current tags, val is the tag that is about to get deleted. Return false to prevent this action.
Public Methods
getTags
Returns a list of objects in the following format:
[{ field: selected input/textarea, editor: editor instance for field, tags: current tags }]
addTag(val, blur)Adds val as a new tag. Set blur to true if focus should not be set automatically into an empty, new tag after this action.
removeTag(val, blur)Removes val as tag. Set blur to true if focus should not be set automatically into an empty, new tag after this action.
destroy Removes the tag editor instance an restores visibility of the original text field or textarea.
Demos
Basic settings
$('#demo1'
'#demo1').tagEditor({
initialTags: ['Hello'
'Hello', 'World'
'World', 'Example'
'Example', 'Tags'
'Tags'],
delimiter: ', '
', ', /* space and comma */
placeholder: 'Enter tags ...'
'Enter tags ...'
});
The original field - textarea or text input - is normally hidden automatically. We show it here to make value changes visible: The placeholder is visible when all tags are deleted and the editor looses focus.
jQuery UI is already loaded on this page - and by default, tags are then sortable via drag and drop. A
utocomplete
For enabling tag autocompletion, make sure to have readily loaded.
You can then pass any options that work with UI autocomplete to your tagEditor settings.
'#demo2').tagEditor({
$('#demo2'
autocomplete: {
delay: 0, // show suggestions immediately
position: { collision: 'flip' }, // automatic menu position up/down
'Asp', ... 'Python'
'Python', 'Ruby'
'Ruby']
'AppleScript', 'Asp'
'ActionScript', 'AppleScript'
source: ['ActionScript'
},
forceLowercase: false,
'Programming languages ...'
placeholder: 'Programming languages ...'
});
Public methods
$('#demo3'
'#demo3').tagEditor({
'World'],
'Hello', 'World'
initialTags: ['Hello'
'Enter tags ...'
placeholder: 'Enter tags ...'
});
getTags
addTag 'example'
removeTag 'example'
Remove all tags
destroy
Init editor
// actions on button clicks
// getTags
'getTags')[0].tags );
alert( $('#demo3'
'#demo3').tagEditor('getTags'
// addTag
'addTag', 'example'
'example');
$('#demo3'
'#demo3').tagEditor('addTag'
/
/ removeTag
'example');
'removeTag', 'example'
$('#demo3'
'#demo3').tagEditor('removeTag'
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论