jQuery和JavaScript相当新鲜,所以请温柔......
我正在开发一个POC来创建一个"列映射"页面,用户可以将"列标题"列表拖放到新列标题的网格中.我需要构建一个可以发送回SQL数据库的数组.我有这个部分(大部分)按照我的意愿运作.
当项目从左侧的列列表拖动到右侧的标题网格时,如果该项目存在,则代码应更新/替换该索引处的数组项目.如果该项不存在,则应将该项添加到数组中.
例如:如果将"First Name"拖动到"Headers",则应将其添加到索引位置0.如果然后将"First Name"拖动到"with",则应删除索引0处的"First Name"值并添加位置1的值.如果然后将"Last Name"拖动到"with",它应该使用"Last Name"值更新位置1的数组.
$(document).ready(() => {
$(function() {
$('.item').draggable({
cursor: "crosshair",
cursorAt: {
left: 5
},
distance: 10,
opacity: 0.75,
revert: true,
snap: ".target",
containment: "window"
});
});
$(function() {
var array = [];
var arraytext = '';
$('.target').droppable({
accept: ".item",
tolerance: 'pointer',
activeClass: 'active',
hoverClass: 'highlight',
drop: function(event, ui) {
var dropped = $(this);
var dragged = $(ui.draggable);
$(function(index, item) {
var test = '';
array.push($(dragged).text());
arraytext = JSON.stringify(array);
test += "Index Value …Run Code Online (Sandbox Code Playgroud)我有一个带有延迟加载模块的 Angular 4.3.6 应用程序。这是一个部分根路由器:
const routes: Routes = [
{ path: '', redirectTo: 'fleet', pathMatch: 'full' },
{
path: '',
component: AppComponent,
canActivate: [AuthenticationGuard],
children: [
{
path: 'fleet',
loadChildren: "./modules/fleet.module",
canActivate: [AuthenticationGuard]
},
{
path: 'password/set',
loadChildren: "./modules/chooseNewPassword.module",
canActivate: [ChoosePasswordGuard]
}
]
}
]
// Exports RouterModule.forRoot(routes, { enableTracing: true });
Run Code Online (Sandbox Code Playgroud)
这两个示例模块中的我的子路由器:
舰队:
RouterModule.forChild([
{
path: '',
component: FleetComponent,
canActivate: [AuthenticationGuard]
}
]);
Run Code Online (Sandbox Code Playgroud)
选择新密码:
RouterModule.forChild([
{
path: '',
component: ChooseNewPasswordComponent,
canActivate: [ChoosePasswordGuard]
}
]);
Run Code Online (Sandbox Code Playgroud)
该AuthenticationGuard调用一个方法,看起来像这样:
return this.getUserSession().map((userSession: …Run Code Online (Sandbox Code Playgroud) 我想从我的复选框中获取值,但我只能得到真或假.
这是我的模板:
<h4>Categories</h4>
<div class="form-check" *ngFor="let cat of categories$|async">
<input class="form-check-input" [(ngModel)]="cat.id" name="{{ cat.name }}" type="checkbox" id="{{cat.name}}">
<label class="form-check-label" for="{{cat.name}}">
{{cat.name}}
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的组件
this.categories$ = this.storeService.getAllCategories().pipe(
map(result => (result as any).data),
tap(r => console.log(r))
)
Run Code Online (Sandbox Code Playgroud)
我的组件基本上从外部api获取类别列表
我在asp.net网站上的某个特定字符上发生换行时遇到问题.我有一个带有'Entitlements'列/字段的用户帐户的gridview,其中使用管道输入数据,如下所示:
"管理|操盘手|支持|销售"
我知道这不是最好的数据架构,但在我们在数据库中添加权利表之前,它必须暂时保持这种状态.
现在,我想在实际的gridview中显示的是:
Admin
Trader
支持
销售
换句话说,我想用换行符替换每个管道,或者至少在每个管道上添加换行符,以便每个权利都在一个单独的行上.
有没有办法在我的CSS类中执行此操作?我查看了不同的属性,如空格,文本溢出和自动换行,但到目前为止,我还没有找到任何可以说"在任何出现此字符时包装文本"的内容.我想我可以使用jQuery来做到这一点,但似乎应该有一个更简单的解决方案.
如果jQuery 是要走的路,那么我将欣赏一个例子,因为我是jQuery的新手.
谢谢你的帮助!
这个问题对许多人来说可能是愚蠢的.我在纯JS中滚动后制作粘性div.有些人可能建议在jQuery中使用它,但我对它不感兴趣.我需要的是类似的东西这个.div在这里一直移动到顶部,但我需要它有60px顶部.我制作了一个剧本,但它不起作用.谁能帮我解决这个问题?
这是我的代码.
HTML
<div id="left"></div>
<div id="right"></div>
Run Code Online (Sandbox Code Playgroud)
CSS
#left{
float:left;
width:100px;
height:200px;
background:yellow;
}
#right{
float:right;
width:100px;
height:1000px;
background:red;
margin-top:200px;
}
Run Code Online (Sandbox Code Playgroud)
JS
window.onscroll = function()
{
var left = document.getElementById("left");
if (left.scrollTop < 60 || self.pageYOffset < 60) {
left.style.position = 'fixed';
left.style.top = '60px';
} else if (left.scrollTop > 60 || self.pageYOffset > 60) {
left.style.position = 'absolute';
left.style.margin-top = '200px';
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我需要实现的目标.左侧div必须具有margin-top:200px和position:absolute页面加载.当用户滚动页面时,左侧div应滚动,当它到达top:60px;其位置时,margin-top应更改为position:fixed和margin-top:60px;
这是FIDDLE
我试图使用write.xlsx编写一个包含523370行和3列的数据帧
write.xlsx(x = dataframe, file = "dataframe.xlsx",
+ sheetName = "dataframe1", row.names = FALSE)
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
Error in .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook") :
Java Exception <no description because toString() failed>.jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook")<S4 object of class "jobjRef">
Run Code Online (Sandbox Code Playgroud)
我检查这些问题:
xlcFreeMemory()然后尝试写入文件,但经过相当长的一段时间后,我得到了同样的错误write.xlsx2()运行这个后给了我同样的错误:options(java.parameters = "-Xmx1024m")并重新启动系统但是这改变了错误改为:
Error in .jcheck(silent = FALSE) :Java Exception <no description because toString() failed>.jcall(row[[ir]], "Lorg/apache/poi/ss/usermodel/Cell;", "createCell", as.integer(colIndex[ic] - 1))<S4 object of class "jobjRef">
Run Code Online (Sandbox Code Playgroud) 我有以下对象,每个人的运动点数.此信息来自数据库,基于搜索"杰克米勒"
Jdata = {
"name": "Jack Miller",
"sports": {
"Basketball": 2,
"Football": 3,
"Iceskating": 5,
"Running": 4,
}
}
Run Code Online (Sandbox Code Playgroud)
我想在我的HTML页面上显示名称的前2(3)项运动.做到这一点,我正在考虑将信息提取到这样的数组中:
SportVal = [];
SportNames = [];
for(var key in this.Jdata.sports){
if(!this.Jdata.sports.hasOwnProperty(key)){
continue;
}
this.SportVal.push(this.Jdata.scores[key]);
this.SportNames.push(key)
}
Run Code Online (Sandbox Code Playgroud)
然后我必须按降序对SportVal数组进行排序,并且可以在HTML中使用例如ngFor来显示结果.
但是,我如何取回相应的名称?此外,我认为这不是最有效的方法,因为如果分数相等,我会遇到问题.所以你可能更好地了解如何做到这一点?
我从react-native开始,我遇到了这个问题:我无法登录到Bundler metro服务器.
如果我使用创建我的应用程序create-react-native-app,我可以执行'console.log'并将值记录到metro bundler(在端口8081上运行).
但如果我用我的应用程序创建react-native init <project>,这不起作用.为了console.log工作,我需要打开Chrome DevTools并在应用程序中设置远程调试.
所以我的问题是:有没有办法让本机代码使用console.log登录bundler控制台?我不想使用'create-react-native-app',因为它使用Expo和'realm'数据库不支持expo.
在Windows和Linux中,我尝试使用react-native 0.55.4和0.56.
我已经在ng update @angular/cli命令的帮助下更新了我的angular-cli .之后,我遇到了Could not determine single project for 'server' target错误跟踪错误.
Could not determine a single project for the 'serve' target.
Error: Could not determine a single project for the 'serve' target.
at ServeCommand.getProjectNamesByTarget (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:175:19)
at ServeCommand.<anonymous> (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:128:51)
at Generator.next (<anonymous>)
at E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:7:71
at new Promise (<anonymous>)
at __awaiter (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:3:12)
at ServeCommand.runArchitectTarget (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:121:16)
at ServeCommand.<anonymous> (E:\Angular\Projects\projectName\node_modules\@angular\cli\commands\serve.js:34:25)
at Generator.next (<anonymous>)
at E:\Angular\Projects\projectName\node_modules\@angular\cli\commands\serve.js:7:71
Run Code Online (Sandbox Code Playgroud)
这种行为让我很困惑.有关更多信息,我也在package.json这里添加.
{
"name": "ProjectName",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": …Run Code Online (Sandbox Code Playgroud) angular ×3
javascript ×3
css ×2
jquery ×2
angular-cli ×1
angular5 ×1
angular6 ×1
asp.net ×1
checkbox ×1
console.log ×1
dart ×1
dataframe ×1
excel ×1
flutter ×1
gridview ×1
ionic3 ×1
json ×1
lazy-loading ×1
line-breaks ×1
logging ×1
r ×1
react-native ×1
scroll ×1
sticky ×1