小编Cas*_*ams的帖子

页面加载时,jQuery选项卡闪烁(FOUC)

我有以下网站:

http://cassidoo.public.iastate.edu/

我在菜单中使用JQuery UI选项卡.加载页面时,选项卡中会有一段内容.

我已尝试从ui-tabs-hide诀窍到隐藏Javascript中的所有内容.有缺点我不知道吗?我该怎么办?

谢谢您的帮助!

javascript jquery jquery-ui jquery-ui-tabs jquery-tabs

6
推荐指数
1
解决办法
1814
查看次数

如何使用Gulp将部分中的JSON和Handlebars组合成HTML?

我正在使用Handlebars和Gulp构建一个静态站点.这是我的文件夹结构:

app/
    content/
        intro.json
        header.json
        faq.json
        features.json
        footer.json
    templates/
        home.hbs
        partials/
            home-section.hbs
            header.hbs
            footer.hbs
    index.html
Gulpfile.js
Run Code Online (Sandbox Code Playgroud)

home.hbs的内容是这样的:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Test</title>
</head>
<body>
    {{> header}}
    {{> home-section}}
    {{> home-section}}
    {{> home-section}}
    {{> footer}}
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我想在传递intro.json,faq.json以及features.json给每个的home-section泛音,并header.json以header和footer.json到页脚.

到目前为止,这是我在Gulpfile中的内容:

var gulp = require('gulp');
var handlebars = require('gulp-compile-handlebars');
var rename = require('gulp-rename');

gulp.task('html', function() {
  return gulp.src('./app/templates/*.hbs')
    .pipe(handlebars({}, {
            ignorePartials: true,
            batch: ['./app/templates/partials']
          }))
    .pipe(rename({
            extname: '.html' …
Run Code Online (Sandbox Code Playgroud)

json handlebars.js gulp gulp-compile-handlebars

6
推荐指数
1
解决办法
2163
查看次数

电子在Windows bash上不能开箱即用

我正在运行Electron的快速启动项目.我在Windows 10上运行bash(操作系统附带的Ubuntu shell).

最初曾与新公共管理和安装了一些问题libasound2,libnss3-dev,libgconf-2-4,libxss1,以及libxtst6解决这些问题.

终于停止了npm错误,但后来得到了这个,我被卡住了:

/electron-quick-start$ npm start

> electron-quick-start@1.0.0 start .../electron-quick-start
> electron .

[1117:1121/213915:FATAL:render_sandbox_host_linux.cc(40)] Check failed: 0 == shutdown(renderer_socket_, SHUT_RD). shutdown: Invalid argument
#0 0x000001e5468e <unknown>
#1 0x000001e6a38b <unknown>
#2 0x000001e6a94d <unknown>
#3 0x00000292cea2 <unknown>
#4 0x0000026f5d75 <unknown>
#5 0x0000026fc0df <unknown>
#6 0x0000026f5506 <unknown>
#7 0x00000121e5b7 <unknown>
#8 0x00000121d090 <unknown>
#9 0x000003475763 main
#10 0x7f43248a1ec5 __libc_start_main
#11 0x000000575dc9 <unknown>
Run Code Online (Sandbox Code Playgroud)

有什么建议?

bash npm windows-10 electron windows-subsystem-for-linux

5
推荐指数
1
解决办法
1572
查看次数

组件中的Redux状态

试图弄清楚如何将Redux存储状态从Redux拉到我的组件中。我已经将mapStateToProps和“连接”连接起来。但是,当我单击“应用”组件中的按钮时,this.props中没有Redux值。

// React and Redux Const
const { Component } = React;
const { render } = ReactDOM;
const { Provider, connect } = ReactRedux;
const {createStore, combineReducers, bindActionCreators } = Redux;



function tweetReducer(state=[],action) {
    if(action.type === 'ADD_TWEET') {
        return state.concat({ id: Date.now(), tweet: action.payload})
    } else {
        return state;
    }
}

const rootReducer = combineReducers ({
    state: (state = {}) => state,
    tweets: tweetReducer
});


class App extends Component{
    buttonClicked() {
        store.dispatch({type: 'ADD_TWEET', payload: 'This is my first 
tweet!'}); …
Run Code Online (Sandbox Code Playgroud)

connect reactjs redux

5
推荐指数
1
解决办法
4099
查看次数

为什么我的文件blob保存整个网页而不是输入的字符串?

我有这个函数接受一个字符串,我希望人们能够下载由该字符串组成的文本文件.但是,每当我单击链接时,下载的文件只包含整个HTML页面而不是字符串.

JS:

function downloadFile(names) {
  var text = names.toString();
  $('#downloadlink').href = createFile(text);
}

function createFile(text) {
  var data = new Blob([text], {type: 'text/plain'});

  if (textFile !== null) {
    window.URL.revokeObjectURL(textFile);
  }

  var textFile = window.URL.createObjectURL(data);

  return textFile;
}
Run Code Online (Sandbox Code Playgroud)

HTML:

<a download="colors.txt" href="" id="downloadlink">Download</a>
Run Code Online (Sandbox Code Playgroud)

它为什么这样做?我是否错误地构建了Blob?我如何解决它?

html javascript blob

4
推荐指数
1
解决办法
120
查看次数

函数返回C中局部变量错误的地址

我有以下代码:

 char* gen()
 {
     char out[256];
     sprintf(out, ...); // you don't need to know what's in here I don't think

     return out;
 }
Run Code Online (Sandbox Code Playgroud)

当我尝试编译时出现此错误:

ERROR: function returns address of local variable
Run Code Online (Sandbox Code Playgroud)

我试过有这个回报率char[],并char没有运气。我错过了什么吗?

c

3
推荐指数
1
解决办法
3075
查看次数

如何在Python中解析文本文件并转换为JSON

我有一个大文件,格式如下:

"string in quotes"
string
string
string
number
|-
Run Code Online (Sandbox Code Playgroud)

...重复一会儿。我正在尝试将其转换为JSON,所以每个块都是这样的:

"name": "string in quotes"
"description": "string"
"info": "string"
"author": "string"
"year": number
Run Code Online (Sandbox Code Playgroud)

这是我到目前为止的内容:

import shutil
import os
import urllib

myFile = open('unformatted.txt','r')
newFile = open("formatted.json", "w")

newFile.write('{'+'\n'+'list: {'+'\n')

for line in myFile:
    newFile.write() // this is where I'm not sure what to write

newFile.write('}'+'\n'+'}')

myFile.close()
newFile.close()
Run Code Online (Sandbox Code Playgroud)

我想我可以对行号进行模运算,但是我不确定这是否是正确的方法。

python scripting json

3
推荐指数
1
解决办法
1万
查看次数

如何在 flexbox 容器中将两个 &lt;div&gt; 分层?

我有一个 flexbox 容器,里面有两个<div>s。一个<div>s 是标题,另一个<div>是隐藏的,直到触发事件。当所述事件被触发时,我想让隐藏的<div>出现在另一个之上。

.container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.header {
  max-width: 600px;
}

#content {
  display: none;
  max-width: 600px;
}

.changed #content {
  display: block;
  z-index: 100;
}

.changed .header {
  opacity: .3;
  z-index: 0;
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
  <div class="header">
    <h1>Heading</h1>
    <h2>Subheading</h2>
    <div class="icons">Icons</div>
  </div>
  <div id="content"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

类.changed是添加到.container呈现#content <div>可见的类。这部分工作正常。

问题是 the.header和#content <div>s 并排出现,即使它们每个都有不同的z-index值。我认为这是因为 flexbox。 …

html css flexbox

3
推荐指数
1
解决办法
5690
查看次数

JavaScript中的内容会导致浏览器崩溃?

我有一个用直接JavaScript编写的应用程序(没有jQuery或任何东西).它的作用是上传一个图像,当你点击它时,它会获得图像的主色,并选择你刚刚在图像中点击的颜色,并根据它生成一个配色方案.

我在这里实现了部分内容:http://cassidoo.co/assets/colordetect/index.html(此版本只有颜色检测部分,而不是颜色选择器/颜色方案部分)

现在,我想弄清楚一些问题.该应用程序通常有效.它不起作用的唯一时间是浏览器崩溃.我在这里看了一下这个帖子:

如何测试潜在的"浏览器崩溃"JavaScript?

我一直在使用我的调试器和所有东西,但是当浏览器崩溃时我实际上并没有收到任何错误.它只是突然没有响应,过了一会儿我得到了"哦,Snap"屏幕或其他东西.

我该怎么调试呢?在我的代码中可能会有什么东西吓坏了(就像它是一个无限循环我没有关闭,画布中的东西是不正常的)?为什么它只发生在50-60%的时间?这是缓存问题吗?

javascript browser debugging canvas

0
推荐指数
1
解决办法
5135
查看次数