小编Ale*_*rff的帖子

Bootstrap手风琴:在折叠或展开元素时如何避免页面滚动

尝试折叠或展开手风琴的元素时,我有意想不到的页面滚动.也许我只是在使用bootstrap网格系统做错了什么?以下是页面示例:

我怎样才能避免这种刺激性的影响呢?
jsfiddle可用https://jsfiddle.net/Lfwvtyms/1/

<body>
<!--default navbar here-->
<main>
    <h1>Long long long long long long header header header header header header lng lasd lewq j</h1>
    <div class="container">
        <div class="row">
            <div class="col-xs-12">
                <div id="task-list">
                    <div id="accordion" role="tablist" aria-multiselectable="true" class="panel-group">

                        <div class="panel panel-default">
                            <div id="headingOne" role="tab" class="panel-heading"><h4 class="panel-title"><a
                                    data-toggle="collapse" data-target="#collapseOne" href="#collapseOne"
                                    aria-expanded="true" aria-controls="collapseOne">First list</a></h4></div>
                            <div id="collapseOne" role="tabpanel" aria-labelledby="headingOne"
                                 class="panel-collapse collapse in">
                                <ul class="list-group">
                                    <li class="list-group-item">Item1</li>
                                    <li class="list-group-item">Item2</li>
                                    <li class="list-group-item">Item3</li>
                                </ul>
                            </div>
                        </div>

                        <div class="panel panel-default">
                            <div id="headingTwo" role="tab" class="panel-heading"><h4 class="panel-title"><a
                                    data-toggle="collapse" data-target="#collapseTwo" …
Run Code Online (Sandbox Code Playgroud)

html css twitter-bootstrap twitter-bootstrap-3

28
推荐指数
4
解决办法
4万
查看次数

何时将功能标记为异步

基本上,async如果await在其中使用,函数必须以关键字作为前缀.但是如果某些函数只返回Promise并且没有等待任何东西,我应该将该函数标记为async

似乎都是正确与否?

// with async (returns Promise)
async getActiveQueue() {
   return redisClient.zrangeAsync(activeQueue, 0, -1);
}

// difference? Both could be awaited isn't it?
getActiveQueue() {
   return redisClient.zrangeAsync(activeQueue, 0, -1);
}
Run Code Online (Sandbox Code Playgroud)

javascript asynchronous async-await ecmascript-2017

16
推荐指数
3
解决办法
1897
查看次数

如何从Qt应用程序检查当前PostgreSQL用户的角色?

我有一些基于Qt库和使用QPSQL驱动程序的应用程序.
在PostreSQL中定义了一些用户角色(例如:admin,operator,user).我的应用程序在指定用户下创建与postgres服务器的连接.如何查看用户角色?

postgresql permissions qt database-design

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

Vue 如何使用 slot 和 slot-props 测试组件

我想测试一下FooComponent

<div>
  <slot :fn="internalFn" />
</div>
Run Code Online (Sandbox Code Playgroud)

它是这样使用的(例如在ParentComponent):

<FooComponent>
  <template slot-scope="slotProps">
    <BarComponent @some-event="slotProps.fn" />
  </template>
</FooComponent>
Run Code Online (Sandbox Code Playgroud)

所以我想测试我的组件在从 slot props 调用这个“fn”时的反应。我看到的最简单的方法是获取方法本身并调用它,如下所示:

cosnt wrapper = shallowMount(FooComponent, /* ... */)
wrapper.vm.methods.internalFn(/* test payload */)
expect(wrapper.emitted()).toBe(/* some expectation */)
Run Code Online (Sandbox Code Playgroud)

但这是众所周知的关于测试内部实现的反模式。所以相反,我想通过fn传递到 slot 的prop 来测试它,因为它也是某种组件接口,就像组件自己的 props。

但是如何测试在插槽中传递的道具?我可以想象它只有在我测试ParentComponent类似的情况下才有效:

const wrapper = shallowMount(ParentComponent, /* ... */)
const foo = wrapper.find(FooComponent)
wrapper.find(BarComponent).vm.$emit('some-event', /*...*/)
/* write expectations against foo */
Run Code Online (Sandbox Code Playgroud)

但这感觉就像FooComponent内部测试的测试ParentComponent

也许有更好的方法来做到这一点?

testing frontend unit-testing vue.js vue-test-utils

9
推荐指数
1
解决办法
5577
查看次数

错误 TS4058:导出函数的返回类型具有或正在使用来自外部模块 Y 的名称 X 但无法命名

使用 tsc v2.2.2

如何修复打字稿编译器错误:

错误 TS4058:导出函数的返回类型具有或正在使用来自外部模块“{some path}/dist/types”的名称“{SomeInterface}”,但无法命名。

我有index.tssomething.ts 的文件夹

// index.ts
import something from './something'

// error will point on this export below
export default function () {
   return {
     resultFunctionFrom: something()
   };
}


// something.ts
import {ICoolInterface} from 'some-module'

export default function () {
  return function (rootOfEvil:ICoolInterface) {
     // ...
  };
}
Run Code Online (Sandbox Code Playgroud)

我会用这样的代码得到这个错误:

错误 TS4058:导出函数的返回类型具有或正在使用来自外部模块“/folder/node_modules/some-module/dist/types”的名称“ICoolInterface”,但无法命名。

typescript typescript-typings typescript2.0

8
推荐指数
2
解决办法
6757
查看次数

如何在测试中手动更新vue计算属性

我有一个Foo带有 Vuex 绑定的组件mockedVuexBinding(本质上是一个计算的 prop)。

我想让测试保持简单,不想嘲笑整个商店。我刚刚在测试中用计算存根替换了所有 vuex 绑定,如下所示:

const wrapper = shallowMount(Foo, {
  computed: {
    mockedVuexBinding: () => 'foo'
  }
}
Run Code Online (Sandbox Code Playgroud)

但事实证明我需要测试 的一些行为Foo,它依赖于计算属性的更改。所以我想用一个值更新我的计算并测试组件如何对其做出反应(例如发出新值)。

没有setComputed类比wrapper.setProps或的方法wrapper.setData,那该怎么办呢?如何用不同的值替换模拟的计算值?

frontend vue.js vuex vuejs2 vue-test-utils

8
推荐指数
1
解决办法
9389
查看次数

反应查询重用项目缓存中的项目

想象一下当您有项目列表和项目视图时的典型用例。

所以有一个端点来获取所有项目。但您也可以使用 获取单个项目/items/:id

但是,如果已从端点获取单个项目,则可以避免获取该项目/items。那么你会如何处理呢react-query

function Items() {
  cosnt itemsQuery = useQuery('items', fetchItems);
  // render items
}
      
function SingleItem({ id }) {
  // you can have another query here and refetch item from server
  // but how to reuse an item from query cache and fetch only if there is no such item?
}
Run Code Online (Sandbox Code Playgroud)

react-query

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

未找到libQt5Core.so所需的libicuuc.so.48(尝试使用-rpath或-rpath-link)

当我试图通过之前运行的程序QtCreator运行时,我收到了此警告.我也得到了这个警告:
libicui18n.so.48, needed by /home/maxim/install/Qt/lib/libQt5Core.so, not found (try using -rpath or -rpath-link)
和(来自libQt5Core.so)十几个错误:
/home/maxim/install/Qt/lib/libQt5Core.so:-1: error: undefined reference to ucnv_fromUnicode_48'
这个问题出现在Ubuntu从13.10升级到14.04之后.我怎样才能解决这个问题?我也尝试安装libicu48

maxim@maxim-VirtualBox:~$ sudo apt-get install libicu48
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libicu48 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libicu48' has no installation candidate
Run Code Online (Sandbox Code Playgroud)

其他变种libicu(libicu48,libicu52-dbg,libicu4j-4.4-java,libicu52,libicu-dev)安装了alredy,但我得到了相同的警告.
当我刚运行任何qt程序时(例如从终端)我得到了这个:./anyprogramm:加载共享库时出错:libicui18n.so.48:无法打开共享对象文件:没有这样的文件或目录

c++ ubuntu qt qmake qt-creator

7
推荐指数
1
解决办法
7174
查看次数

SQL完全连接没有任何条件

我正在使用MS SQL.
我有以下表格:

table A:
    id1   data1
    8234    ko
    2       po
    333     koo
    40      woo

table B:
    id2     data2
    123     meow
    654     frrr

table C:
    id3     data3
    10          a
    20          b
    30          c
    40          d
    50          e   
    60          f
Run Code Online (Sandbox Code Playgroud)

我想得到这个:

    id1     data1       id2     data2       id3     data3
    8234    ko          123      meow        10         a
    2       po          654      frrr        20         b
    333     koo         NULL     NULL        30         c
    40      woo         NULL     NULL        40         d
    NULL    NULL        NULL     NULL        50         e
    NULL    NULL        NULL     NULL …
Run Code Online (Sandbox Code Playgroud)

sql t-sql sql-server

7
推荐指数
2
解决办法
2万
查看次数

如何使用 cypress 断言输入值是真实的

我有一些输入

<input />
Run Code Online (Sandbox Code Playgroud)

如何断言输入具有真实值?

我认为这是可能的

cy('input').should('not.have.value', '')
Run Code Online (Sandbox Code Playgroud)

但我认为它有点不可靠。或者可能不是。但无论如何,知道一些其他方法来检查真实值会很高兴。

cypress

7
推荐指数
1
解决办法
8012
查看次数