想让用户选择并复制open System.Collections.Generic
let total = 10000000
let outer = 10
let inner = total / outer
let stopWatch =
let sw = System.Diagnostics.Stopwatch ()
sw.Start ()
sw
let timeIt (name : string) (a : unit -> 'T) : unit = // '
let t = stopWatch.ElapsedMilliseconds
let v = a ()
for i = 1 to (outer - 1) do
a () |> ignore
let d = stopWatch.ElapsedMilliseconds - t
printfn "%s, elapsed %d ms, result %A" name d v
let case1 () =
// Slow because it fallbacks into slow but safe code pattern
let mutable x = 0
for i in seq{1..inner} do
x <- x+1
x
let case2 () =
// Fast because the optimization in TypeChecker.fs matches
let mutable x = 0
for i in 1..inner do
x <- x+1
x
let case3 () =
// Slow because the optimization in TypeChecker.fs requires int32
let mutable x = 0
for i in 1L..int64 inner do
x <- x+1
x
let case4 () =
// Slow because the optimization in TypeChecker.fs doesn't recognize b..inc..e patterns
let mutable x = 0
for i in 1..2..inner do
x <- x+1
x
let case5 () =
// Fast because Optimizer.fs recognizes this pattern
let mutable x = 0
for i in 1..1..inner do
x <- x+1
x
let case6 () =
// Fast because Optimizer.fs recognizes this pattern
let mutable x = 0
for i in inner..(-1)..1 do
x <- x+1
x
[<EntryPoint>]
let main argv =
timeIt "case1" case1
timeIt "case2" case2
timeIt "case3" case3
timeIt "case4" case4
timeIt "case5" case5
timeIt "case6" case6
0
按钮标签。它应该像一个标签。根据此question无法在Bootstrap对话框页脚中使用标签。怎么做?
bootstrap
答案 0 :(得分:1)
从用户体验的角度来看,我不明白你为什么要那样做。我的意思是,一个按钮用于号召性用语。复制文本时,是否应该发生号召性用语?我认为你最好使用文本元素或段落来复制文本。
然而,有多种方法可以在按钮中选择文本。这是我通过在按钮中放置一个文本字段来做的一个简单示例。
https://jsfiddle.net/o8eze0d2/
您可以通过添加按钮
添加来选择文本时禁用按钮操作if (event.target === this)
或在执行
的文本字段上添加onmousedown侦听器调用event.stopPropagation();