我是JavaScript的新手,我不太确定在我的应用程序中使用的以下遗留淘汰赛和JS代码:
file1.js:
var FbPicturesObj = {
fbPicturesVM: new FbPicturesVM(),
initialize: function () {
ko.applyBindings(FbPicturesObj.fbPicturesVM, $("#fb-albums")[0]);
ko.applyBindings(FbPicturesObj.fbPicturesVM, $("#fb-album-photos")[0]);
},
Reset: function Reset() {
FbPicturesObj.fbPicturesVM.albums([]);
FbPicturesObj.fbPicturesVM.photos([]);
}
}
Run Code Online (Sandbox Code Playgroud)
file2.js:
function FbPicturesVM() {
...... some code ....
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:
FbPicturesObj.fbPicturesVM都会在内存中创建fbPicturesVM的新实例吗?ko.applyBindings调用正确写入?(在代码优化方面)非常感谢.
有没有人知道在 HTML 元素上悬停时滑动长文本的 Angular 指令?如果可能的话,我不喜欢使用 jQuery 插件。
目前,文本正在使用 css 截断,但我希望能够在将鼠标悬停在其上时向用户显示剩余的字符。
任何替代解决方案也受到热烈欢迎。
我的HTML:
<div class="name"><span>{{ field.name }}</span>
Run Code Online (Sandbox Code Playgroud)
我的CSS:
span {
padding: 0 10px;
font-size: 16px;
font-weight: 100;
line-height: 32px;
text-overflow: ellipsis;
overflow: hidden;
display: block;
white-space: nowrap;
}
Run Code Online (Sandbox Code Playgroud) 一直试图在我的 VueJS 项目中使用故事书,但我一直坚持模拟 api 调用。我尝试使用 axios-mock-adapter 没有运气。
我的故事书文件代码是:
import { storiesOf } from '@storybook/vue';
import { action } from '@storybook/addon-actions';
import { withKnobs, boolean } from '@storybook/addon-knobs';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import fileUpload from './fileUpload.vue';
const mock = new MockAdapter(axios);
mock
.onPost('https://s3.amazonaws.com')
.reply(200, []);
storiesOf('Common|File CSV Upload', module)
.addDecorator(withKnobs)
.add('Default', () => ({
components: { fileUpload },
data: () => ({
}),
template: `
<v-flex>
<file-upload></file-upload>
</v-flex>`,
methods: {
action: action('file upload'),
},
}));
Run Code Online (Sandbox Code Playgroud)
我用对了吗?
我有这种格式的对象数组:
var full_list = [
{
"pid": 1,
"items":[
{"item_id": '9'},
{"item_id": '10'},
{"item_id": '12'}
]
},
{
"pid": 2,
"items":[
{"item_id": '33'},
{"item_id": '22'},
{"item_id": '65'}
]
}...
];
Run Code Online (Sandbox Code Playgroud)
我有一个tmp数组,它由完整数组中的对象组成:
var tmp_list = [
{
"pid": 2,
"items":[
{"item_id": '33'},
{"item_id": '22'},
{"item_id": '65'}
]
}, {....}
Run Code Online (Sandbox Code Playgroud)
我想过滤掉完整列表中的对象,其中至少有一个selectedIDs值出现在对象的项目的id数组中
var selectedIDs = {'1', '9', '45', ....};
Run Code Online (Sandbox Code Playgroud)
然后将它们添加到tmp列表中.
我尝试使用过滤器,但我没有完全搞清楚.
谢谢.
selectedIDs.forEach(function(id) {
var tmp = full_list.filter(function (obj) {
obj.items.forEach(function (item) {
if (item.id === id) {
console.log('found');
}
});
});
tmp_list.push(tmp); …Run Code Online (Sandbox Code Playgroud) 我在bootstrap模态窗口中使用angular-ui-select和~1500项的列表.
用户执行的每个操作都会延迟2秒.我试图通过使用'minimum-input-length'来提高性能,但过滤器不起作用.
Plunkr示例:https://plnkr.co/edit/H0kbeR4kHfZFjsBnpjBC ? p = preview
我的Html:
<ui-select multiple sortable="true" ng-model="vm.selected" theme="select2" style="width: 100%;">
<ui-select-match placeholder="Select...">{{ $item.name }}</ui-select-match>
<ui-select-choices repeat="item in vm.items | filter: $select.search" minimum-input-length="2">
<div ng-bind-html="item.name | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
Run Code Online (Sandbox Code Playgroud)
如何申请最小字符过滤?
谢谢.
我需要创建文本字段的帮助,该文本字段内部有一个图标,并在该图标上附加了工具提示。我的代码:
<v-text-field
v-model="url">
<span slot="label">Url
<v-tooltip bottom>
<v-icon
slot="activator"
color="primary"
dark
>home</v-icon>
<span>Tooltip</span>
</v-tooltip>
</span>
</v-text-field>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
谢谢。
我需要帮助将以下 es6 循环转换为 es5 代码。
for (let [field_name, field] of impList) {
//// some code
}
Run Code Online (Sandbox Code Playgroud)
谢谢。
javascript ×4
angularjs ×2
arrays ×1
axios ×1
css ×1
ecmascript-5 ×1
ecmascript-6 ×1
filter ×1
html ×1
jquery ×1
knockout.js ×1
storybook ×1
ui-select ×1
vue.js ×1
vuetify.js ×1