问题列表 - 第34539页

常规JavaScript可以与jQuery混合使用吗?

例如,我可以使用此脚本(来自mozilla教程):

<html>
 <head>
  <script type="application/javascript">
    function draw() {
      var canvas = document.getElementById("canvas");
      if (canvas.getContext) {
        var ctx = canvas.getContext("2d");

        ctx.fillStyle = "rgb(200,0,0)";
        ctx.fillRect (10, 10, 55, 50);

        ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
        ctx.fillRect (30, 30, 55, 50);
      }
    }
  </script>
 </head>
 <body onload="draw();">
   <canvas id="canvas" width="150" height="150"></canvas>
 </body>
</html>
Run Code Online (Sandbox Code Playgroud)

并将此JavaScript与jQuery的document.ready混合而不是依赖于onload?

javascript jquery

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

error C2375: redefinition; different linkage

Error place in api:

#define DLLEXPORT extern "C" __declspec(dllexport)
DLLEXPORT int CAnyseeUSBTVControllerDlg::InitCaptureDevice()
{
Run Code Online (Sandbox Code Playgroud)

In my .h library class and function definition:

class CAnyseeUSBTVControllerDlg : public CDialog
{
// Construction
public:
    int InitCaptureDevice(void);
Run Code Online (Sandbox Code Playgroud)

Any idea how to resolve it?

"Error 1 error C2375: 'CAnyseeUSBTVControllerDlg::InitCaptureDevice' : redefinition; different linkage c:\Program Files\toATS_DVS\anysee\anyseee30\anyseee30\anyseeUSBTVControllerDlg.cpp 122 anyseee30"

c++ redefinition

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

何时使用$ sth-> fetchrow_hashref,$ sth-> fetchrow_arrayref和$ sth-> fetchrow_array?

我知道:

  • $sth->fetchrow_hashref 从数据库返回获取的行的hashref,
  • $sth->fetchrow_arrayref 从数据库返回获取的行的arrayref,和
  • $sth->fetchrow_array 从数据库返回获取的行的数组.

但我想知道有关这些的最佳实践.我们什么时候应该使用fetchrow_hashref?什么时候应该使用fetchrow_arrayref?什么时候应该使用fetchrow_array?

perl dbi

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

子类化MKAnnotationView并覆盖setDragState

这是关于使用MKMapKit的iPhone App:

我为可拖动的注释创建了一个自定义MKAnnotationView.我想创建一个自定义动画.我设置了一个自定义图钉图像,注释是可拖动的(这里没有显示,它发生在mapview中),代码如下:

- (void) movePinUpFinished {

     [super setDragState:MKAnnotationViewDragStateDragging];
     [self setDragState:MKAnnotationViewDragStateDragging];
}

- (void) setDragState:(MKAnnotationViewDragState) myState {
     if (myState == MKAnnotationViewDragStateStarting) {
          NSLog(@"starting");
          CGPoint endPoint = CGPointMake(self.center.x,self.center.y-20);
          self.center = endPoint;
          [self movePinUpFinished];
     }
     if (myState == MKAnnotationViewDragStateEnding) {
          NSLog(@"ending");
          [super setDragState:MKAnnotationViewDragStateEnding];
          [self setDragState:MKAnnotationViewDragStateNone];
          [super setDragState:MKAnnotationViewDragStateNone];
     }
     if (myState == MKAnnotationViewDragStateDragging) {
          NSLog(@"dragging");
     }
     if (myState == MKAnnotationViewDragStateCanceling) {
          NSLog(@"cancel");
     }
     if (myState == MKAnnotationViewDragStateNone) {
          NSLog(@"none");
     }
}
Run Code Online (Sandbox Code Playgroud)

一切正常,注释向上移动一点,可拖动,当我发布注释时,mapview会收到"dragstateending".

但现在我希望动画在一段时间内运行并将dragStateStarting更改为以下内容:

if (myState == MKAnnotationViewDragStateStarting) {
          NSLog(@"starting");
          CGPoint endPoint = CGPointMake(self.center.x,self.center.y-20); …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch mapkit ios4

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

IDEA JetBrains IntelliJ - 在'make'上编译错误,但在使用Maven编译时没有错误,IntelliJ在类文件中没有报告错误

所以我在IntelliJ中有一个maven模块(模块-A).我最近将一些类从它移动到另一个新的maven模块(模块-B)并添加了一个依赖项.一旦我完成了这个,我还修改了一个移动类的方法的签名(现在在模块B中).

我重新导入了poms,以便IntelliJ获取依赖项更改并确保受影响文件的所有Java导入再次正确.现在,当我尝试运行我的webapp(取决于两个模块)时,我在module-A中的类中遇到编译错误,调用模块-B中类的修改方法.

错误消息基本上是说该方法不存在但认为旧方法仍然存在!我点击'make'错误,它将我带到模块A中的一个类中,调用修改后的方法...奇怪的是,IntelliJ知道它在文件中很好.ie该方法没有加下划线,就像编译错误一般,但类文件名是:(

我使用'mvn install'(也安装了模块-B)从命令行编译它并且它都是成功的.我删除了模块A和模块B的目标中的classes目录,并且还使IntelliJ的缓存失效并重新启动......仍在发生......任何想法?

java maven-2 compilation intellij-idea

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

任务栏位置

如何检测任务栏的位置?我需要知道在右上角显示我的通知.谢谢

编辑:谢谢Hans Passant.我用它来获取位置.我希望没事.

GetTaskbarLocation(TaskbarPosition.GetTaskbarPosition());

private void GetTaskbarLocation(Rectangle rc)
{
    if (rc.X == rc.Y)
    {
        if (rc.Right < rc.Bottom)
            taskbarLocation = TaskbarLocation.Left;
        if (rc.Right > rc.Bottom)
            taskbarLocation = TaskbarLocation.Top;
    }
    if (rc.X > rc.Y)
        taskbarLocation = TaskbarLocation.Right;
    if (rc.X < rc.Y)
        taskbarLocation = TaskbarLocation.Bottom;
}
Run Code Online (Sandbox Code Playgroud)

c#

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

如何在Python中将u'\\ u4f60 \\ u4f60'之类的unicode字符串转换为u'\ u4f60\u4f60'?

我使用正则表达式从html源文件中捕获字符串:

f = open(rrfile, 'r')
p = re.compile(r'"name":"([^"]+)","head":"([^"]+)"')
match = re.findall(p, f.read())
Run Code Online (Sandbox Code Playgroud)

我试过了:

>>> u'\\u4f60\\u4f60'.replace('\\u', '\u')  
u'\\u4f60\\u4f60'  
>>> u'\\u4f60\\u4f60'.replace(u'\\u', '\u')  
u'\\u4f60\\u4f60'  
>>> u'\\u4f60\\u4f60'.replace('\\u', u'\u')  
File "<stdin>", line 1  
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: end of string in escape sequence  
Run Code Online (Sandbox Code Playgroud)

这可以通过str.replace()来完成吗?还是需要更复杂的东西?

python unicode replace

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

如何将多级数组中的唯一值映射到value => array的散列?

我有一个看起来像这样的数组:

[[100, "one"],
 [101, "one"],
 [102, "one"],
 [103, "two"],
 [104, "three"],
 [105, "three"]]
Run Code Online (Sandbox Code Playgroud)

我想要做的是创建一个看起来像这样的哈希数组

[{"one" => [100,101,102]},
 {"two" => [103]},
 {"three" => [104,105]}]
Run Code Online (Sandbox Code Playgroud)

数字部分将始终是唯一的,字符串部分将具有重复项.我想到这样做的每一种方式我都有一些很长的功能,我想知道实现这个问题的"轨道方式",我确信有一些我不知道的模糊功能.

ruby arrays hash ruby-on-rails hashmap

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

是否可以将汇编指令放入CUDA代码中?

我想在CUDA C代码中使用汇编代码,以减少昂贵的执行,因为我们在c编程中使用asm.

可能吗?

c assembly cuda inline-assembly ptx

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

DOM使用jquery逐个遍历节点

我想通过维护序列在网页上逐节点遍历.

以下是基本DOM:

<BODY>
     <DIV id ='1'> Test 1 </DIV>
     <DIV id='2'> Details about <SPAN id='3'> Execution </SPAN> </DIV>   
</BODY>
Run Code Online (Sandbox Code Playgroud)

按照上面的例子,我想逐个节点遍历每个节点

1st Traversal : <BODY>

2nd Traversal : <DIV id ='1'>

3rd Traversal : <DIV id='2'>

4rd Traversal : <SPAN id='3'>
Run Code Online (Sandbox Code Playgroud)

我的动机是遍历当前页面上可用的所有节点,并逐个访问每个节点,简单地说是nextnode(),而不是查看父和子关系.Exepcted是,它应该按照以下顺序访问每个节点.

所以我的发言是这样的:

startnode //consider this is start node

While ( startnode!=null ) {

  // will process on startnode

   startnode= startnode->nextnode();
  // something like that to visit each node
}
Run Code Online (Sandbox Code Playgroud)

有谁知道这个,如何使用jquery(最好)或javascript实现这一点,请分享他们的参考.

谢谢

-Pravin

html javascript jquery dom

5
推荐指数
2
解决办法
7673
查看次数